When running a script for the first time using the GroovyScriptEngine, if two or more concurrent threads try to run it, it is possible that a concurrency issue happens when accessing updateCacheEntry at
groovy.util.GroovyScriptEngine.updateCacheEntry(GroovyScriptEngine.java:285)
I think this is due that the private Map "dependencies"
at
groovy.util.GroovyScriptEngine$ScriptCacheEntry.dependencies (GroovyScriptEngine.java:101)
is not synchronized. It could be solved by:
private Map dependencies= Collections.synchronizedMap(new HashMap());
I have attached my test case (to be run by executing the main method) and a sample groovy script.