Skip to content

Commit

Permalink
Tweaks around accessing SuiteResult
Browse files Browse the repository at this point in the history
Closes #3078

Following changes were made:

* Removed the lock based synchronization around 
SuiteResult because it’s already backed by a 
SynchronizedMap from Collections.
* Altered the getter such that it returns back a
regular linkedHashMap (without the synchronisation
Because users are expected ONLY to iterate on it and
NOT change its state)
* Also just to ensure that users don’t garble the 
Suite result, wrapping it with an UnModifiableMap
  • Loading branch information
krmahadevan committed Mar 22, 2024
1 parent f8d722e commit 7180ae4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions testng-core/src/main/java/org/testng/SuiteRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public class SuiteRunner implements ISuite, ISuiteRunnerListener {

private static final String DEFAULT_OUTPUT_DIR = "test-output";

private final Map<String, ISuiteResult> suiteResults =
Collections.synchronizedMap(Maps.newLinkedHashMap());
private final Map<String, ISuiteResult> suiteResults = Maps.newLinkedHashMap();
private final List<TestRunner> testRunners = Lists.newArrayList();
private final Map<Class<? extends ISuiteListener>, ISuiteListener> listeners =
Maps.newLinkedHashMap();
Expand Down Expand Up @@ -514,7 +513,9 @@ public String getOutputDirectory() {

@Override
public Map<String, ISuiteResult> getResults() {
return suiteResults;
// Just to ensure that we guard the internals of the suite results we now wrap it
// around with an unmodifiable map.
return Collections.unmodifiableMap(suiteResults);
}

/**
Expand Down

0 comments on commit 7180ae4

Please sign in to comment.