On Thu, 20 Aug 2026 16:08:27 GMT, Dušan Bálek <[email protected]> wrote:

>> Running two or more `jlink` invocations concurrently in the same JVM through 
>> the `ToolProvider` API causes the simultaneous `run` calls to interfere with 
>> one another, even when each invocation targets a distinct `--output` 
>> directory and the invocations share no inputs. They may fail with errors 
>> such as:
>> 
>> Error: java.lang.IllegalStateException: stream has already been operated 
>> upon or closed
>> Error: Resource XYZ already present
>> 
>> The problem is that Main.run(...) correctly creates a new `JlinkTask` for 
>> each call, but `JlinkTask` defeats this isolation by sharing static 
>> `TaskHelper` and `OptionsHelper` instances. Concurrent invocations can 
>> therefore overwrite one another’s parsed options and plugin pipelines.
>> 
>> The proposed solution is to make `taskHelper` and `optionsHelper` instance 
>> fields of `JlinkTask`. This preserves actual concurrency. Synchronizing the 
>> provider would unnecessarily serialize image creation and would not protect 
>> separate provider instances or direct calls to `Main.run(...)`.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Dušan Bálek has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Test updated.

Good. I assume you'll run tier1-3 before integrating.

-------------

Marked as reviewed by alanb (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/32469#pullrequestreview-4985125906

Reply via email to