mirror of
https://github.com/apache/maven.git
synced 2025-03-06 16:49:27 +00:00
cleanup: release artifact resolver resources more eagerly
Set resolver executor thread context classloader to null by default. This allows collection of class realms that triggered thread creation (one of plugin realms, typically). Use Disposable#dispose to shutdown resolver executor server, remove now redundant #finilaze() implementation. Signed-off-by: Igor Fedorenko <ifedorenko@apache.org>
This commit is contained in:
parent
2909b5a329
commit
a5b92f2d03
@ -60,6 +60,7 @@
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable;
|
||||
import org.eclipse.aether.RepositorySystem;
|
||||
import org.eclipse.aether.RepositorySystemSession;
|
||||
import org.eclipse.aether.repository.LocalRepositoryManager;
|
||||
@ -71,7 +72,7 @@
|
||||
*/
|
||||
@Component( role = ArtifactResolver.class )
|
||||
public class DefaultArtifactResolver
|
||||
implements ArtifactResolver
|
||||
implements ArtifactResolver, Disposable
|
||||
{
|
||||
@Requirement
|
||||
private Logger logger;
|
||||
@ -120,17 +121,6 @@ public void execute( Runnable command )
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize()
|
||||
throws Throwable
|
||||
{
|
||||
if ( executor instanceof ExecutorService )
|
||||
{
|
||||
( (ExecutorService) executor ).shutdown();
|
||||
}
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
private RepositorySystemSession getSession( ArtifactRepository localRepository )
|
||||
{
|
||||
return LegacyLocalRepositoryManager.overlay( localRepository, legacySupport.getRepositorySession(), repoSystem );
|
||||
@ -571,6 +561,7 @@ public Thread newThread( Runnable r )
|
||||
{
|
||||
Thread newThread = new Thread( GROUP, r, "resolver-" + THREAD_NUMBER.getAndIncrement() );
|
||||
newThread.setDaemon( true );
|
||||
newThread.setContextClassLoader( null );
|
||||
return newThread;
|
||||
}
|
||||
}
|
||||
@ -640,4 +631,13 @@ public void run()
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose()
|
||||
{
|
||||
if ( executor instanceof ExecutorService )
|
||||
{
|
||||
( (ExecutorService) executor ).shutdownNow();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user