Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.0
-
Fix Version/s: 1.1-beta-2
-
Component/s: groovy-jdk
-
Labels:None
-
Environment:Linux/Windows
-
Testcase included:yes
-
Number of attachments :
Description
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.
the dependencies map is now ThreadLocal, which solves your issue too