[MNG-5206] plexus container never disposed

Submitted by Stuart McCulloch.

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1211692 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-12-07 22:55:08 +00:00
parent 65507bcfde
commit 50b6e3b621
1 changed files with 9 additions and 2 deletions

View File

@ -180,6 +180,7 @@ public class MavenCli
// TODO: need to externalize CliRequest // TODO: need to externalize CliRequest
public int doMain( CliRequest cliRequest ) public int doMain( CliRequest cliRequest )
{ {
PlexusContainer localContainer = this.container;
try try
{ {
initialize( cliRequest ); initialize( cliRequest );
@ -188,7 +189,7 @@ public class MavenCli
logging( cliRequest ); logging( cliRequest );
version( cliRequest ); version( cliRequest );
properties( cliRequest ); properties( cliRequest );
container( cliRequest ); localContainer = container( cliRequest );
commands( cliRequest ); commands( cliRequest );
settings( cliRequest ); settings( cliRequest );
populateRequest( cliRequest ); populateRequest( cliRequest );
@ -218,6 +219,10 @@ public class MavenCli
} }
finally finally
{ {
if ( localContainer != this.container )
{
localContainer.dispose();
}
if ( cliRequest.fileStream != null ) if ( cliRequest.fileStream != null )
{ {
cliRequest.fileStream.close(); cliRequest.fileStream.close();
@ -353,7 +358,7 @@ public class MavenCli
populateProperties( cliRequest.commandLine, cliRequest.systemProperties, cliRequest.userProperties ); populateProperties( cliRequest.commandLine, cliRequest.systemProperties, cliRequest.userProperties );
} }
private void container( CliRequest cliRequest ) private PlexusContainer container( CliRequest cliRequest )
throws Exception throws Exception
{ {
if ( cliRequest.classWorld == null ) if ( cliRequest.classWorld == null )
@ -414,6 +419,8 @@ public class MavenCli
settingsBuilder = container.lookup( SettingsBuilder.class ); settingsBuilder = container.lookup( SettingsBuilder.class );
dispatcher = (DefaultSecDispatcher) container.lookup( SecDispatcher.class, "maven" ); dispatcher = (DefaultSecDispatcher) container.lookup( SecDispatcher.class, "maven" );
return container;
} }
private PrintStreamLogger setupLogger( CliRequest cliRequest ) private PrintStreamLogger setupLogger( CliRequest cliRequest )