mirror of https://github.com/apache/maven.git
[MNG-4925] Mismanagement of container lookup realm can cause type incompatibilities for plugins looking up components by string
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1042237 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5f05f63b1e
commit
51a0476667
|
@ -86,8 +86,10 @@ public class DefaultBuildPluginManager
|
||||||
throw new PluginExecutionException( mojoExecution, project, e );
|
throw new PluginExecutionException( mojoExecution, project, e );
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassRealm oldLookupRealm = container.getLookupRealm();
|
ClassRealm oldLookupRealm = container.setLookupRealm( pluginRealm );
|
||||||
|
|
||||||
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
|
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
|
||||||
|
Thread.currentThread().setContextClassLoader( pluginRealm );
|
||||||
|
|
||||||
MavenSession oldSession = legacySupport.getSession();
|
MavenSession oldSession = legacySupport.getSession();
|
||||||
|
|
||||||
|
@ -95,8 +97,6 @@ public class DefaultBuildPluginManager
|
||||||
{
|
{
|
||||||
mojo = mavenPluginManager.getConfiguredMojo( Mojo.class, session, mojoExecution );
|
mojo = mavenPluginManager.getConfiguredMojo( Mojo.class, session, mojoExecution );
|
||||||
|
|
||||||
Thread.currentThread().setContextClassLoader( pluginRealm );
|
|
||||||
|
|
||||||
legacySupport.setSession( session );
|
legacySupport.setSession( session );
|
||||||
|
|
||||||
// NOTE: DuplicateArtifactAttachmentException is currently unchecked, so be careful removing this try/catch!
|
// NOTE: DuplicateArtifactAttachmentException is currently unchecked, so be careful removing this try/catch!
|
||||||
|
@ -158,12 +158,8 @@ public class DefaultBuildPluginManager
|
||||||
{
|
{
|
||||||
mavenPluginManager.releaseMojo( mojo, mojoExecution );
|
mavenPluginManager.releaseMojo( mojo, mojoExecution );
|
||||||
|
|
||||||
if ( oldLookupRealm != null )
|
|
||||||
{
|
|
||||||
container.setLookupRealm( null );
|
|
||||||
}
|
|
||||||
|
|
||||||
Thread.currentThread().setContextClassLoader( oldClassLoader );
|
Thread.currentThread().setContextClassLoader( oldClassLoader );
|
||||||
|
container.setLookupRealm( oldLookupRealm );
|
||||||
|
|
||||||
legacySupport.setSession( oldSession );
|
legacySupport.setSession( oldSession );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue