[ 
https://issues.apache.org/jira/browse/GROOVY-7407?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17914353#comment-17914353
 ] 

Jex Jexler commented on GROOVY-7407:
------------------------------------

I have tested a bit...

*Summary*

Appears that Ivy's {{artifact-lock-nio}} locking is buggy: It works to some 
degree, but can still lead to problems in practice.

(I remember that I had already tried this setting a few years ago in a 
container ([Jexler|https://grengine.ch/jexler/]) that would start several 
grabbing) Groovy scripts each in their own threads when starting, and I still 
had issues then, i.e. I know of at least one practical example where using 
{{artifact-lock-nio}} is not good enough.

*Details*

See [https://github.com/alainstalder/GROOVY-7407] for details, especially 
[RESULTS-2025-01-18.md|https://github.com/alainstalder/GROOVY-7407/blob/main/RESULTS-2025-01-18.md]
 there.

Also attaching that repo here as [^GROOVY-7407-main.zip]

> Compilation not thread safe if Grape / Ivy is used in Groovy scripts
> --------------------------------------------------------------------
>
>                 Key: GROOVY-7407
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7407
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler, Grape
>    Affects Versions: 2.4.3
>         Environment: 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.
>            Reporter: Jex Jexler
>            Assignee: Daniel Sun
>            Priority: Minor
>              Labels: Compile, Grape, Groovy, Ivy
>             Fix For: 5.0.0-alpha-12, 4.0.25, 3.0.24
>
>         Attachments: GROOVY-7407-Jenkins-Pipeline.txt, GROOVY-7407-main.zip, 
> GrabConcurrencyTest.java, GrapeAndGroovyShellConcurrencyTest.java, 
> GroovyCompileConcurrencyTest.java, 
> WorkaroundGroovy7407WrappingGrapeEngine.java, 
> stacktrace-GrapeAndGroovyShellConcurrencyTest-1.txt, 
> stacktrace-GrapeAndGroovyShellConcurrencyTest-2.txt, 
> stacktrace-GroovyCompileConcurrencyTest-1.txt, 
> stacktrace-GroovyCompileConcurrencyTest-2.txt
>
>
> 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).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to