google / google/closure-compiler
java.util.ConcurrentModificationException in compiler
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
If I run multiple instances of the compiler simultaneously, by running multiple CommandLineRunners on different threads, I occasionally get java.util.ConcurrentModificationExceptions. The stack I get is:
ERROR: java.util.ConcurrentModificationException
java.util.concurrent.ExecutionException: java.util.ConcurrentModificationException
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
at org.chromium.closure.compiler.Runner.runWithExecutor(Runner.java:121)
at org.chromium.closure.compiler.Runner.run(Runner.java:105)
at org.chromium.closure.compiler.Runner.main(Runner.java:176)
Caused by: java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:859)
at java.util.ArrayList$Itr.next(ArrayList.java:831)
at com.google.javascript.jscomp.CommandLineRunner$Flags.getMixedJsSources(CommandLineRunner.java:898)
at com.google.javascript.jscomp.CommandLineRunner.initConfigFromFlags(CommandLineRunner.java:1283)
at com.google.javascript.jscomp.CommandLineRunner.(CommandLineRunner.java:1140)
at org.chromium.closure.compiler.Runner$LocalCommandLineRunner.(Runner.java:184)
at org.chromium.closure.compiler.Runner$CompilerRunner.call(Runner.java:231)
at org.chromium.closure.compiler.Runner$CompilerRunner.call(Runner.java:217)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Looking at the code the problem seems to be that code is iterating through a synchonizedList without synchronizing on it. See [CommandLineRunner:898](https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/CommandLineRunner.java#L898) and the warning in [synchronizedList](https://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#synchronizedList%28java.util.List%29)
Contributor guide
Assessment
This issue has not been assessed yet.