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

Compilation not thread safe if Grape / Ivy is used in Groovy scripts

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.4.3
    • None
    • Compiler, Grape
    • Essentially independent of the environment, as long as Groovy scripts use Grape; also this bug seems to be present since at least Groovy 1.7.5.

    Description

      If Groovy scripts that import the same libraries via Grape are compiled in separate threads, compilation may fail due to race conditions.

      This does not happen if several threads use the same instance of GroovyClassLoader (GCL), because parseClass() uses synchronization.

      But as soon as different GCLs are used in separate threads or if the compiler is used directly (CompilationUnit.compile()), the issue occurs and compilation can fail.

      Two Java unit tests have be attached, which reproduce the issue, although this cannot be guaranteed with 100% certainty, because there is a race condition.

      Two different stacktraces have been observed for each unit test (with origins in Grape and in Ivy), which have also been attached (plus in a different environment (Tomcat webapp CentOS) once a an exception down in Ivy had been observed that seemed to be related to unzipping a JAR file, but no precise record of that exists any more).

      Attachments

        1. GroovyCompileConcurrencyTest.java
          2 kB
          Jex Jexler
        2. GrapeAndGroovyShellConcurrencyTest.java
          3 kB
          Jex Jexler
        3. stacktrace-GroovyCompileConcurrencyTest-1.txt
          0.7 kB
          Jex Jexler
        4. stacktrace-GroovyCompileConcurrencyTest-2.txt
          5 kB
          Jex Jexler
        5. stacktrace-GrapeAndGroovyShellConcurrencyTest-1.txt
          4 kB
          Jex Jexler
        6. stacktrace-GrapeAndGroovyShellConcurrencyTest-2.txt
          2 kB
          Jex Jexler
        7. WorkaroundGroovy7407WrappingGrapeEngine.java
          5 kB
          Jex Jexler
        8. GrabConcurrencyTest.java
          3 kB
          Jex Jexler
        9. GROOVY-7407-Jenkins-Pipeline.txt
          61 kB
          Jesse Glick

        Activity

          People

            Unassigned Unassigned
            jexler Jex Jexler
            Votes:
            2 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated: