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

NullPointerException when running two or more scripts with GroovyScriptEngine in multiple threads .

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 1.1-beta-1
    • 1.1-beta-2
    • groovy-jdk
    • None
    • Windows XP SP2 / Sun JDK1.5..0_09

    Description

      NullPointerException is always thrown when running the two scripts in multiple threads with the same GroovyScriptEngine instance.

      Besides the NPE,the result is not correct sometime.

      Here is a wrong result:
      java.lang.NullPointerException
      at groovy.util.GroovyScriptEngine$ScriptCacheEntry.access$502(GroovyScriptEngine.java:101)
      at groovy.util.GroovyScriptEngine.updateCacheEntry(GroovyScriptEngine.java:358)
      at groovy.util.GroovyScriptEngine.run(GroovyScriptEngine.java:395)
      at GroovyConcurrentTest$ScriptRunner.run(GroovyConcurrentTest.java:63)
      run :script2.groovy result:script2
      run :script3.groovy result:null
      run :script2.groovy result:script2
      run :script2.groovy result:script2
      run :script2.groovy result:script2
      run :script2.groovy result:script2
      run :script2.groovy result:script2
      run :script2.groovy result:script2
      run :script2.groovy result:script2
      run :script2.groovy result:script2
      run :script2.groovy result:script2
      run :script2.groovy result:script2
      run :script2.groovy result:script2
      run :script2.groovy result:script2
      run :script3.groovy result:script2
      run :script3.groovy result:script2
      run :script3.groovy result:script2
      run :script3.groovy result:script2
      run :script3.groovy result:script2
      run :script3.groovy result:script2
      run :script2.groovy result:script2
      run :script2.groovy result:script2
      run :script2.groovy result:script2
      run :script2.groovy result:script2
      run :script2.groovy result:script2
      run :script2.groovy result:script2
      run :script3.groovy result:script2
      run :script3.groovy result:script2
      run :script3.groovy result:script2
      run :script3.groovy result:script2
      run :script3.groovy result:script2
      run :script3.groovy result:script2
      run :script3.groovy result:script2
      run :script3.groovy result:script2
      run :script3.groovy result:script2
      run :script3.groovy result:script2
      run :script3.groovy result:script2
      run :script3.groovy result:script2
      run :script3.groovy result:script2

      I extpect the resut looks like this:
      run :script2.groovy result:script2
      run :script3.groovy result:script3

      Maybe the NPE is caused by the currentCacheEntry is null?

      Attachments

        1. GroovyScriptEngine.patch
          2 kB
        2. test.zip
          1 kB

        Activity

          People

            blackdrag Jochen Theodorou
            d0ngw Dongyong Wang
            Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: