rmannibucau commented on code in PR #210: URL: https://github.com/apache/maven-shade-plugin/pull/210#discussion_r1460418023
########## src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java: ########## @@ -1112,15 +1116,21 @@ private void rewriteDependencyReducedPomIfWeHaveReduction( w.close(); } - ProjectBuildingRequest projectBuildingRequest = - new DefaultProjectBuildingRequest(session.getProjectBuildingRequest()); - projectBuildingRequest.setLocalRepository(session.getLocalRepository()); - projectBuildingRequest.setRemoteRepositories(project.getRemoteArtifactRepositories()); + // Lock critical section to fix MSHADE-467 + try { Review Comment: ``` diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java index 3a7eaaa..a8475d9 100644 --- a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java +++ b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java @@ -35,8 +35,6 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; @@ -1050,8 +1048,6 @@ public class ShadeMojo extends AbstractMojo { rewriteDependencyReducedPomIfWeHaveReduction(dependencies, modified, transitiveDeps, model); } - private static final Lock LOCK = new ReentrantLock(); - private void rewriteDependencyReducedPomIfWeHaveReduction( List<Dependency> dependencies, boolean modified, List<Dependency> transitiveDeps, Model model) throws IOException, ProjectBuildingException, DependencyGraphBuilderException { @@ -1116,9 +1112,7 @@ public class ShadeMojo extends AbstractMojo { w.close(); } - // Lock critical section to fix MSHADE-467 - try { - LOCK.lock(); + synchronized (session.getProjectBuildingRequest()) { // Lock critical section to fix MSHADE-467 ProjectBuildingRequest projectBuildingRequest = new DefaultProjectBuildingRequest(session.getProjectBuildingRequest()); projectBuildingRequest.setLocalRepository(session.getLocalRepository()); @@ -1128,8 +1122,6 @@ public class ShadeMojo extends AbstractMojo { getLog().debug("updateExcludesInDeps()"); modified = updateExcludesInDeps(result.getProject(), dependencies, transitiveDeps); - } finally { - LOCK.unlock(); } } ``` can you give a try to that and check it is sufficient for you please? should fix your issue without putting a global bottleneck in the mojo (previous comment is still accurate, no strong opinion on lock vs synchronized as of today, just want a bottleneck per project to avoid a bottleneck in complex projects). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org