Skip to content

Commit

Permalink
Merge pull request #29 from tomtom-international/fix/concurrentModifi…
Browse files Browse the repository at this point in the history
…cationException

fix: fix ConcurrentModificationException
  • Loading branch information
pwielgolaski authored Jan 15, 2020
2 parents dade2df + fc98deb commit 4e266e3
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,13 @@ public boolean contains(String className) {

@Override
public Set<Class> getChildren(String className) {
return (container.get(className) != null) ? container.get(className) : new HashSet<>();
return (container.get(className) != null) ? new HashSet<>(container.get(className) ): new HashSet<>();
}

// FIXME - if you want to implement multithreaded classScanner there is the point that multithreading pitfall is waiting for you - it's not threadsafe !!!!!
@Override
public void addChild(String className, Class<?> clazz) {
container.computeIfAbsent(className, key -> new HashSet<>());
Set<Class> classSet = container.get(className);
classSet.add(clazz);
container.put(className, classSet);
public synchronized void addChild(String className, Class<?> clazz) {
container.computeIfAbsent(className, key -> new HashSet<>())
.add(clazz);
}

@Override
Expand Down

0 comments on commit 4e266e3

Please sign in to comment.