Skip to content

Commit

Permalink
Fixing data races
Browse files Browse the repository at this point in the history
  • Loading branch information
krmahadevan committed Jun 6, 2023
1 parent 31db07e commit ffa0d95
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

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

public static <V> Set<V> newConcurrentHashSet() {
return ConcurrentHashMap.newKeySet();
}

public static <V> Set<V> newHashSet(Collection<V> c) {
return new HashSet<>(c);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ protected void invokeBeforeClassMethods(ITestClass testClass, IMethodInstance mi
Map<ITestClass, Set<Object>> invokedBeforeClassMethods =
m_classMethodMap.getInvokedBeforeClassMethods();
Set<Object> instances =
invokedBeforeClassMethods.computeIfAbsent(testClass, key -> Sets.newHashSet());
invokedBeforeClassMethods.computeIfAbsent(testClass, key -> Sets.newConcurrentHashSet());
Object instance = mi.getInstance();
if (!instances.contains(instance)) {
instances.add(instance);
Expand Down

0 comments on commit ffa0d95

Please sign in to comment.