Skip to content
New issue

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

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

Already on GitHub? # to your account

Fixing data races #2921

Merged
merged 1 commit into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
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
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