Skip to content

Commit

Permalink
[MNG-7402] BuildListCalculator never detaches the classloader
Browse files Browse the repository at this point in the history
This closes #683
  • Loading branch information
Christoph Läubrich authored and michael-o committed Feb 26, 2022
1 parent 395411f commit d29af90
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,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();

This comment has been minimized.

Copy link
@gnodet

gnodet Feb 28, 2022

Contributor

The call to get the tccl could have been moved outside the loop.

This comment has been minimized.

Copy link
@michael-o

michael-o Feb 28, 2022

Member

Well, we had this, but the attach happens on a per-project base. For consistency reasons we made it per-project as well.

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 );
Expand Down

0 comments on commit d29af90

Please sign in to comment.