[
https://issues.apache.org/jira/browse/MNG-7402?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17495072#comment-17495072
]
Michael Osipov commented on MNG-7402:
-------------------------------------
Like this?
{noformat}
diff --git
a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/BuildListCalculator.java
b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/BuildListCalculator.java
index 9000c9301e..c35ac4134c 100644
---
a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/BuildListCalculator.java
+++
b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/BuildListCalculator.java
@@ -60,10 +60,18 @@ public ProjectBuildList calculateProjectBuilds(
MavenSession session, List<TaskS
}
for ( MavenProject project : projects )
{
- BuilderCommon.attachToThread( project ); // Not totally sure
if this is needed for anything
- MavenSession copiedSession = session.clone();
- copiedSession.setCurrentProject( project );
- projectBuilds.add( new ProjectSegment( project, taskSegment,
copiedSession ) );
+ ClassLoader tccl =
Thread.currentThread().getContextClassLoader();
+ try
+ {
+ BuilderCommon.attachToThread( project ); // Not totally
sure if this is needed for anything
+ MavenSession copiedSession = session.clone();
+ copiedSession.setCurrentProject( project );
+ projectBuilds.add( new ProjectSegment( project,
taskSegment, copiedSession ) );
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader( tccl );
+ }
}
}
return new ProjectBuildList( projectBuilds );
{noformat}
> BuildListCalculator never detaches the classlaoder...
> -----------------------------------------------------
>
> Key: MNG-7402
> URL: https://issues.apache.org/jira/browse/MNG-7402
> Project: Maven
> Issue Type: Bug
> Reporter: Christoph Läubrich
> Priority: Major
>
> https://github.com/apache/maven/blob/6b607109d3ce045106924139e96705fe7c42172e/maven-core/src/main/java/org/apache/maven/lifecycle/internal/BuildListCalculator.java#L63
> Her there is attachToThread called but never detached. This seems to be a
> leak, at least the threads current contextclassloader is never restored.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)