Skip to content

Fix NPE when adding cleanup hook #2252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions compiler/test/dotty/tools/vulpix/RunnerOrchestration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package tools
package vulpix

import java.io.{ File => JFile, InputStreamReader, BufferedReader, PrintStream }
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.TimeoutException

import scala.concurrent.duration.Duration
Expand Down Expand Up @@ -84,11 +85,11 @@ trait RunnerOrchestration {
}

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

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