fix(maven): synchronize batch runner invoke() to prevent concurrent access#34600
Merged
FrozenPandaz merged 1 commit intomasterfrom Feb 27, 2026
Merged
fix(maven): synchronize batch runner invoke() to prevent concurrent access#34600FrozenPandaz merged 1 commit intomasterfrom
FrozenPandaz merged 1 commit intomasterfrom
Conversation
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
View your CI Pipeline Execution ↗ for commit 455e590
☁️ Nx Cloud last updated this comment at |
f5d87b7 to
75719ae
Compare
75719ae to
ce0663b
Compare
…access Maven 4's ResidentMavenInvoker (LookupInvoker.invoke()) is not thread-safe — it snapshots/restores System.getProperties() and the thread context classloader in a finally block, and all concurrent invocations share the same resident MavenContext. The batch runner's parallel thread pool can call invoke() from multiple threads simultaneously when tasks are independent roots in the task graph, which can cause deadlocks in Maven's internal session machinery. Add @synchronized to both Maven 3 and Maven 4 adapter invoke() methods to serialize Maven executions through the shared invoker instance. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2b42b9e to
455e590
Compare
Contributor
🐳 We have a release for that!This PR has a release associated with it. You can try it out using this command: npx create-nx-workspace@22.6.0-pr.34600.455e590 my-workspaceOr just copy this version and use it in your own command: 22.6.0-pr.34600.455e590
To request a new release for this pull request, mention someone from the Nx team or the |
FrozenPandaz
approved these changes
Feb 27, 2026
FrozenPandaz
pushed a commit
that referenced
this pull request
Mar 4, 2026
…ccess (#34600) ## Current Behavior The Maven batch runner uses a parallel thread pool to execute tasks. When multiple tasks are independent roots in the task graph, they get picked up by separate threads simultaneously. Both threads call `invoke()` on the same shared `CachingResidentMavenInvoker` (Maven 4) or `CachingMaven3Invoker` (Maven 3) instance concurrently. Maven 4's `LookupInvoker.invoke()` is not thread-safe — it snapshots/restores `System.getProperties()` and the thread context classloader in a `finally` block, and all concurrent invocations share the same resident `MavenContext`. This can cause deadlocks in Maven's internal session machinery. ## Expected Behavior Maven executions through the shared invoker are serialized via `@Synchronized`, preventing concurrent access to non-thread-safe Maven internals. The parallel thread pool still handles task graph management, build state recording, and result emission concurrently. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> (cherry picked from commit 53c0123)
4 tasks
Contributor
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current Behavior
The Maven batch runner uses a parallel thread pool to execute tasks. When multiple tasks are independent roots in the task graph, they get picked up by separate threads simultaneously. Both threads call
invoke()on the same sharedCachingResidentMavenInvoker(Maven 4) orCachingMaven3Invoker(Maven 3) instance concurrently.Maven 4's
LookupInvoker.invoke()is not thread-safe — it snapshots/restoresSystem.getProperties()and the thread context classloader in afinallyblock, and all concurrent invocations share the same residentMavenContext. This can cause deadlocks in Maven's internal session machinery.Expected Behavior
Maven executions through the shared invoker are serialized via
@Synchronized, preventing concurrent access to non-thread-safe Maven internals. The parallel thread pool still handles task graph management, build state recording, and result emission concurrently.