diff --git a/CHANGES.txt b/CHANGES.txt index c92c2cf8b..45b226567 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,6 @@ Current +Fixed: GITHUB-727 : Fixing data races (Krishnan Mahadevan) Fixed: GITHUB-2913: Maps containing nulls can be incorrectly considered equal (Alex Heneveld) 7.8.0 diff --git a/testng-collections/src/main/java/org/testng/collections/Sets.java b/testng-collections/src/main/java/org/testng/collections/Sets.java index af616522e..c375623b1 100644 --- a/testng-collections/src/main/java/org/testng/collections/Sets.java +++ b/testng-collections/src/main/java/org/testng/collections/Sets.java @@ -5,6 +5,7 @@ import java.util.HashSet; import java.util.LinkedHashSet; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; public final class Sets { @@ -14,6 +15,10 @@ public static Set newHashSet() { return new HashSet<>(); } + public static Set newConcurrentHashSet() { + return ConcurrentHashMap.newKeySet(); + } + public static Set newHashSet(Collection c) { return new HashSet<>(c); } diff --git a/testng-core/src/main/java/org/testng/internal/ExitCodeListener.java b/testng-core/src/main/java/org/testng/internal/ExitCodeListener.java index 440525613..adbc9d581 100644 --- a/testng-core/src/main/java/org/testng/internal/ExitCodeListener.java +++ b/testng-core/src/main/java/org/testng/internal/ExitCodeListener.java @@ -12,7 +12,7 @@ import org.testng.xml.XmlSuite; public class ExitCodeListener implements ITestListener, IReporter, IExecutionListener { - private boolean hasTests = false; + private volatile boolean hasTests = false; private final ExitCode status = new ExitCode(); private boolean failIfAllTestsSkipped = false; @@ -64,12 +64,6 @@ public void onTestFailedButWithinSuccessPercentage(ITestResult result) { this.hasTests = true; } - @Override - public void onStart(ITestContext context) {} - - @Override - public void onFinish(ITestContext context) {} - @Override public void onExecutionFinish() { if (failIfAllTestsSkipped && (getStatus().getExitCode() == ExitCode.SKIPPED)) { diff --git a/testng-core/src/main/java/org/testng/internal/invokers/TestMethodWorker.java b/testng-core/src/main/java/org/testng/internal/invokers/TestMethodWorker.java index 77f6db75d..a192f309c 100644 --- a/testng-core/src/main/java/org/testng/internal/invokers/TestMethodWorker.java +++ b/testng-core/src/main/java/org/testng/internal/invokers/TestMethodWorker.java @@ -161,7 +161,7 @@ protected void invokeBeforeClassMethods(ITestClass testClass, IMethodInstance mi Map> invokedBeforeClassMethods = m_classMethodMap.getInvokedBeforeClassMethods(); Set instances = - invokedBeforeClassMethods.computeIfAbsent(testClass, key -> Sets.newHashSet()); + invokedBeforeClassMethods.computeIfAbsent(testClass, key -> Sets.newConcurrentHashSet()); Object instance = mi.getInstance(); if (!instances.contains(instance)) { instances.add(instance);