Avoid making NPEs out of OOMEs!

(cherry picked from commit ba29f65f17c7b9d9ac5bf79d0934cf23438a16b4)
This commit is contained in:
Dale Wijnand 2020-05-19 12:19:50 +01:00
parent 85c1c63176
commit ff97fb6068
1 changed files with 2 additions and 1 deletions

View File

@ -151,7 +151,8 @@ object MainLoop {
case Left(t) => state.handleError(t) case Left(t) => state.handleError(t)
} }
} catch { } catch {
case oom: OutOfMemoryError if oom.getMessage.contains("Metaspace") => case oom: OutOfMemoryError
if oom.getMessage != null && oom.getMessage.contains("Metaspace") =>
System.gc() // Since we're under memory pressure, see if more can be freed with a manual gc. System.gc() // Since we're under memory pressure, see if more can be freed with a manual gc.
val isTestOrRun = state.remainingCommands.headOption.exists { exec => val isTestOrRun = state.remainingCommands.headOption.exists { exec =>
val cmd = exec.commandLine val cmd = exec.commandLine