Ilya Lipnitskiy created GROOVY-9574:
---------------------------------------

             Summary: ConcurrentModificationException in 
Java9.concealedPackageList
                 Key: GROOVY-9574
                 URL: https://issues.apache.org/jira/browse/GROOVY-9574
             Project: Groovy
          Issue Type: Bug
          Components: groovy-runtime
    Affects Versions: 3.x
         Environment: Groovy v3.0.3
# java -version
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed mode)

            Reporter: Ilya Lipnitskiy


Facing the following exception in a multithreaded environment with multiple 
threads executing the same Groovy code (@CompileStatic is not used). HashMap is 
not reentrant, but computeIfAbsent may insert an element if a key is missing. 
If another thread is iterating through the map at the same time, I can see why 
this exception is being raised. Is the fix as simple as replacing HashMap with 
ConcurrentHashMap, or are there performance implications?

java.util.ConcurrentModificationException

at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1134)
 at org.codehaus.groovy.vmplugin.v9.Java9.concealedPackageList(Java9.java:402)
 at 
org.codehaus.groovy.vmplugin.v9.Java9.isExportedForIllegalAccess(Java9.java:373)
 at org.codehaus.groovy.vmplugin.v9.Java9.checkAccessible(Java9.java:353)
 at org.codehaus.groovy.vmplugin.v9.Java9.doTransformMetaMethod(Java9.java:266)
 at 
org.codehaus.groovy.vmplugin.v9.Java9.getOrTransformMetaMethod(Java9.java:253)
 at org.codehaus.groovy.vmplugin.v9.Java9.transformMetaMethod(Java9.java:244)
 at org.codehaus.groovy.vmplugin.v8.Java8.transformMetaMethod(Java8.java:613)
 at 
org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSite.<init>(PojoMetaMethodSite.java:184)
 at 
org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrap.<init>(PojoMetaMethodSite.java:198)
 at 
org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.createCachedMethodSite(PojoMetaMethodSite.java:160)
 at 
org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.createPojoMetaMethodSite(PojoMetaMethodSite.java:151)
 at groovy.lang.MetaClassImpl.createPojoCallSite(MetaClassImpl.java:3487)
 at 
org.codehaus.groovy.runtime.callsite.CallSiteArray.createPojoSite(CallSiteArray.java:123)
 at 
org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:160)
 at 
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
 at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
 at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to