Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9574

ConcurrentModificationException in Java9.concealedPackageList

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.x
    • 4.0.0-alpha-1, 3.0.5
    • groovy-runtime
    • None
    • 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)

    Description

      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)
      

      Attachments

        Activity

          People

            daniel_sun Daniel Sun
            lipnitsk Ilya Lipnitskiy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: