Details
Description
If Groovy scripts that import the same libraries via Grape are compiled in separate threads, compilation may fail due to race conditions.
This does not happen if several threads use the same instance of GroovyClassLoader (GCL), because parseClass() uses synchronization.
But as soon as different GCLs are used in separate threads or if the compiler is used directly (CompilationUnit.compile()), the issue occurs and compilation can fail.
Two Java unit tests have be attached, which reproduce the issue, although this cannot be guaranteed with 100% certainty, because there is a race condition.
Two different stacktraces have been observed for each unit test (with origins in Grape and in Ivy), which have also been attached (plus in a different environment (Tomcat webapp CentOS) once a an exception down in Ivy had been observed that seemed to be related to unzipping a JAR file, but no precise record of that exists any more).