Skip to content

Commit ac2bc22

Browse files
committed
Tweaks around accessing SuiteResult
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
1 parent 69dc232 commit ac2bc22

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

testng-core/src/main/java/org/testng/SuiteRunner.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ public class SuiteRunner implements ISuite, ISuiteRunnerListener {
3434

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

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

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

520521
/**

0 commit comments

Comments
 (0)