Skip to content

Commit ec7755a

Browse files
committed
Catch all throwables to avoid docker crashing
1 parent c43fb0b commit ec7755a

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/main/scala/codacy/dockerApi/DockerEngine.scala

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,18 @@ abstract class DockerEngine(Tool: Tool) {
4646
}))
4747

4848
log("tool started")
49-
Tool(
50-
path = sourcePath,
51-
conf = maybePatterns,
52-
files = maybeFiles
53-
)
49+
try {
50+
Tool.apply(
51+
path = sourcePath,
52+
conf = maybePatterns,
53+
files = maybeFiles
54+
)
55+
} catch {
56+
// We need to catch Throwable here to avoid JVM crashes
57+
// Crashes can lead to docker not exiting properly
58+
case e: Throwable =>
59+
Failure(e)
60+
}
5461
}
5562
} match {
5663
case Success(results) =>
@@ -67,7 +74,7 @@ abstract class DockerEngine(Tool: Tool) {
6774
System.exit(0)
6875
case Failure(error) =>
6976
error.printStackTrace(Console.err)
70-
System.exit(1)
77+
Runtime.getRuntime.halt(1)
7178
}
7279
}
7380

0 commit comments

Comments
 (0)