Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
1.0-JSR-4
-
None
-
None
-
* Pentium IV 3.0Ghz HT, Windows XP, 1.5Gb Memory
* Dual Pentium Xeon 3.0Ghz HT, Fedora 3 Core Linux, 4Gb Memory
Description
Apparently, there are a concurrency bug on GroovyShell that shows up when compiling scripts simultaneously on different threads.
I developed a test case that shows the problem.
Please, note that each thread creates its own GroovyShell instance and there is no shared data between threads. Even then, sometimes groovy shell throws and Exception.
I got 3 different exceptions already. The most common one is:
General error during class generation: java.util.ConcurrentModificationException
Less frequently, but also happens several times:
java.lang.NullPointerException
And an exception that I got only 3 times was:
java.lang.OutOfMemoryError
Concurrency problems, as you know are not deterministic by nature, so sometimes it happens, sometimes it doesn't. So, please execute the test case several times. Eventually it will raise one exception or another. Also, the computers where I'm running the test are all HyperThread, so they have (from an Operating System point of view) 2 and 4 processors, respectivelly. The problem happens both on Windows and Linux. Although, the OutOfMemoryError I got only in Linux.
Also, if I try to debug the test case, using Eclipse, the errors simply don't occur. As I don't know the groovy internals (I downloaded the source code), I was not able to advance much more on the problem analysis.
Bellow I paste the stack trace for the errors and I attached the test case.
This is affecting my production system using groovy. As a workaround I'm synchronizing all threads when parsing scripts, but this is critical for the application, so it is really not good to have to do this. This is why I cathegorized the issue as critical.
Let me know if you need any other information.
Thanks in advance.
Edson