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

Concurrency issue when loading dependencies in the GroovyScriptEngine

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0
    • 1.1-beta-2
    • groovy-jdk
    • None
    • Linux/Windows

    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.

      Attachments

        1. TestFilesOpen.java
          2 kB
          David Costa Faidella
        2. Test2.groovy
          0.5 kB
          David Costa Faidella

        Activity

          People

            blackdrag Jochen Theodorou
            dcosta72 David Costa Faidella
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: