Issue Details (XML | Word | Printable)

Key: GROOVY-1930
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Jochen Theodorou
Reporter: David Costa Faidella
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
groovy

Concurrency issue when loading dependencies in the GroovyScriptEngine

Created: 01/Jun/07 10:23 AM   Updated: 05/Jul/07 05:13 AM
Component/s: groovy-jdk
Affects Version/s: 1.0
Fix Version/s: 1.1-beta-2

Time Tracking:
Not Specified

File Attachments: 1. File Test2.groovy (0.5 kB)
2. Java Source File TestFilesOpen.java (2 kB)

Environment: Linux/Windows

Testcase included: yes


 Description  « Hide
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.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Jochen Theodorou added a comment - 05/Jul/07 05:13 AM
the dependencies map is now ThreadLocal, which solves your issue too