Skip to content

Commit d6767b5

Browse files
committed
Fixing data races
Closes #727
1 parent 31db07e commit d6767b5

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Current
22

3+
Fixed: GITHUB-727 : Fixing data races (Krishnan Mahadevan)
34
Fixed: GITHUB-2913: Maps containing nulls can be incorrectly considered equal (Alex Heneveld)
45

56
7.8.0

testng-collections/src/main/java/org/testng/collections/Sets.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.HashSet;
66
import java.util.LinkedHashSet;
77
import java.util.Set;
8+
import java.util.concurrent.ConcurrentHashMap;
89

910
public final class Sets {
1011

@@ -14,6 +15,10 @@ public static <V> Set<V> newHashSet() {
1415
return new HashSet<>();
1516
}
1617

18+
public static <V> Set<V> newConcurrentHashSet() {
19+
return ConcurrentHashMap.newKeySet();
20+
}
21+
1722
public static <V> Set<V> newHashSet(Collection<V> c) {
1823
return new HashSet<>(c);
1924
}

testng-core/src/main/java/org/testng/internal/ExitCodeListener.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import org.testng.xml.XmlSuite;
1313

1414
public class ExitCodeListener implements ITestListener, IReporter, IExecutionListener {
15-
private boolean hasTests = false;
15+
private volatile boolean hasTests = false;
1616
private final ExitCode status = new ExitCode();
1717
private boolean failIfAllTestsSkipped = false;
1818

@@ -64,12 +64,6 @@ public void onTestFailedButWithinSuccessPercentage(ITestResult result) {
6464
this.hasTests = true;
6565
}
6666

67-
@Override
68-
public void onStart(ITestContext context) {}
69-
70-
@Override
71-
public void onFinish(ITestContext context) {}
72-
7367
@Override
7468
public void onExecutionFinish() {
7569
if (failIfAllTestsSkipped && (getStatus().getExitCode() == ExitCode.SKIPPED)) {

testng-core/src/main/java/org/testng/internal/invokers/TestMethodWorker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ protected void invokeBeforeClassMethods(ITestClass testClass, IMethodInstance mi
161161
Map<ITestClass, Set<Object>> invokedBeforeClassMethods =
162162
m_classMethodMap.getInvokedBeforeClassMethods();
163163
Set<Object> instances =
164-
invokedBeforeClassMethods.computeIfAbsent(testClass, key -> Sets.newHashSet());
164+
invokedBeforeClassMethods.computeIfAbsent(testClass, key -> Sets.newConcurrentHashSet());
165165
Object instance = mi.getInstance();
166166
if (!instances.contains(instance)) {
167167
instances.add(instance);

0 commit comments

Comments
 (0)