mirror of https://github.com/apache/maven.git
exit session scope in finally {} block
Signed-off-by: Igor Fedorenko <ifedorenko@apache.org>
This commit is contained in:
parent
6b79ac5e33
commit
e2a0792840
|
@ -170,19 +170,32 @@ public class DefaultMaven
|
|||
return addExceptionToResult( result, e );
|
||||
}
|
||||
|
||||
DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) newRepositorySession( request );
|
||||
|
||||
MavenSession session = new MavenSession( container, repoSession, request, result );
|
||||
|
||||
//
|
||||
// We enter the session scope right after the MavenSession creation and before any of the AbstractLifecycleParticipant lookups
|
||||
// so that @SessionScoped components can be @Injected into AbstractLifecycleParticipants.
|
||||
//
|
||||
sessionScope.enter();
|
||||
sessionScope.seed( MavenSession.class, session );
|
||||
try
|
||||
{
|
||||
DefaultRepositorySystemSession repoSession =
|
||||
(DefaultRepositorySystemSession) newRepositorySession( request );
|
||||
MavenSession session = new MavenSession( container, repoSession, request, result );
|
||||
|
||||
legacySupport.setSession( session );
|
||||
sessionScope.seed( MavenSession.class, session );
|
||||
|
||||
legacySupport.setSession( session );
|
||||
|
||||
return doExecute( request, session, result, repoSession );
|
||||
}
|
||||
finally
|
||||
{
|
||||
sessionScope.exit();
|
||||
}
|
||||
}
|
||||
|
||||
private MavenExecutionResult doExecute( MavenExecutionRequest request, MavenSession session,
|
||||
MavenExecutionResult result, DefaultRepositorySystemSession repoSession )
|
||||
{
|
||||
try
|
||||
{
|
||||
for ( AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( Collections.<MavenProject>emptyList() ) )
|
||||
|
@ -321,10 +334,6 @@ public class DefaultMaven
|
|||
{
|
||||
return addExceptionToResult( result, e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
sessionScope.exit();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
Loading…
Reference in New Issue