classgraph: ConcurrentModificationException while getting ScanResult output

Sometimes this happens:

java.util.ConcurrentModificationException
 	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:937)
 	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:891)
 	at io.github.classgraph.ScanResult.getResourcesMatchingPattern(ScanResult.java:383)

My call looks innocent enough:

val configUrls = new ClassGraph().scan()
    .getResourcesMatchingPattern(configRegex.r.pattern)
    .asScala
    .map(_.getURL)

Is it possible to fix it?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 45 (27 by maintainers)

Commits related to this issue

Most upvoted comments

Eh, I’ve uncovered a pandora’s box. My world will never be the same.

Though the conclusion is simple: we must never use finalizers except of situations when our app is completely independent of when they may be executed and if they may be executed. Crap-crap-crap.