Skip to content

Commit 195fe4a

Browse files
Merge pull request #2252 from dotty-staging/fix/npe-in-cleanup-hook
Fix NPE when adding cleanup hook
2 parents 742f881 + 5b1ae60 commit 195fe4a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

compiler/test/dotty/tools/vulpix/RunnerOrchestration.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package tools
33
package vulpix
44

55
import java.io.{ File => JFile, InputStreamReader, BufferedReader, PrintStream }
6+
import java.util.concurrent.atomic.AtomicBoolean
67
import java.util.concurrent.TimeoutException
78

89
import scala.concurrent.duration.Duration
@@ -84,11 +85,11 @@ trait RunnerOrchestration {
8485
}
8586

8687
/** Did add hook to kill the child VMs? */
87-
private[this] var didAddCleanupCallback = false
88+
private[this] val didAddCleanupCallback = new AtomicBoolean(false)
8889

8990
/** Blocks less than `maxDuration` while running `Test.main` from `dir` */
9091
def runMain(classPath: String)(implicit summaryReport: SummaryReporting): Status = {
91-
if (!didAddCleanupCallback) {
92+
if (didAddCleanupCallback.compareAndSet(false, true)) {
9293
// If for some reason the test runner (i.e. sbt) doesn't kill the VM, we
9394
// need to clean up ourselves.
9495
summaryReport.addCleanup(killAll)

0 commit comments

Comments
 (0)