You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2026/10/17 11:45:01 UTC
(maven-toolchains-plugin) branch master updated: Remove unnecessary static synchronization in ToolchainMojo (#180)
This is an automated email from the ASF dual-hosted git repository.
elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-toolchains-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new cef5d79 Remove unnecessary static synchronization in ToolchainMojo (#180)
cef5d79 is described below
commit cef5d794a6984f731626233857ba846c3a4cbec8
Author: Elliotte Rusty Harold <el...@users.noreply.github.com>
AuthorDate: Sat Oct 17 11:44:55 2026 +0000
Remove unnecessary static synchronization in ToolchainMojo (#180)
* Remove unnecessary static synchronization in ToolchainMojo
Fixes #174
The static LOCK object and synchronized block around
toolchainManagerPrivate.storeToolchainToBuildContext() are unnecessary
because:
1. The plugin is marked threadSafe=true, meaning Maven may execute it
concurrently for different modules/sessions
2. storeToolchainToBuildContext() stores data into the build context,
which is already per-session and thread-safe
3. The static lock introduces unnecessary contention: one module's
toolchain selection blocks another unrelated module's selection,
defeating the purpose of threadSafe=true
In multi-module Maven builds where the toolchains plugin runs in
multiple modules, the static lock serializes what could otherwise run
in parallel, slowing down builds.
* remove unused variable
---
src/main/java/org/apache/maven/plugins/toolchain/ToolchainMojo.java | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugins/toolchain/ToolchainMojo.java b/src/main/java/org/apache/maven/plugins/toolchain/ToolchainMojo.java
index c106f83..8d05838 100644
--- a/src/main/java/org/apache/maven/plugins/toolchain/ToolchainMojo.java
+++ b/src/main/java/org/apache/maven/plugins/toolchain/ToolchainMojo.java
@@ -47,7 +47,6 @@ import org.apache.maven.toolchain.ToolchainPrivate;
configurator = "toolchains-requirement-configurator",
threadSafe = true)
public class ToolchainMojo extends AbstractMojo {
- private static final Object LOCK = new Object();
private final ToolchainManagerPrivate toolchainManagerPrivate;
@@ -147,9 +146,7 @@ public class ToolchainMojo extends AbstractMojo {
getLog().info("Found matching toolchain for type " + type + ": " + tc);
// store matching toolchain to build context
- synchronized (LOCK) {
- toolchainManagerPrivate.storeToolchainToBuildContext(tc, session);
- }
+ toolchainManagerPrivate.storeToolchainToBuildContext(tc, session);
return true;
}