Skip to content

Commit

Permalink
Use ConcurrentHashMap for possible concurrent execution in the future
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed May 3, 2017
1 parent bdcb452 commit 0f91ab3
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

package org.junit.platform.engine.support.hierarchical;

import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import org.junit.platform.engine.TestDescriptor;
import org.junit.platform.engine.UniqueId;
Expand All @@ -21,7 +21,7 @@
*/
class ExecutionTracker {

private final Set<UniqueId> executedUniqueIds = new HashSet<>();
private final Set<UniqueId> executedUniqueIds = ConcurrentHashMap.newKeySet();

void markExecuted(TestDescriptor testDescriptor) {
executedUniqueIds.add(testDescriptor.getUniqueId());
Expand Down

2 comments on commit 0f91ab3

@jbduncan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh! It wouldn't have occurred to me to look in ConcurrentHashMap for a method to produce a ConcurrentHashSet - I would've probably gone for Collections.newSetFromMap(new ConcurrentHashMap<>) instead, without really knowing if it produced thread-safe behaviour.

One learns something new everyday. 😉

@sbrannen
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.