Skip to content

Commit

Permalink
MNG-5578 fixed guice OutOfScopeException during multithreaded build
Browse files Browse the repository at this point in the history
This was a regression since 3.2.1 introduced by my commit 48fec94

Signed-off-by: Igor Fedorenko <[email protected]>
  • Loading branch information
ifedorenko committed May 22, 2014
1 parent 65863e0 commit 702acd2
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.HashSet;
import java.util.List;

import org.apache.maven.SessionScope;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.execution.BuildSuccess;
import org.apache.maven.execution.ExecutionEvent;
Expand Down Expand Up @@ -64,6 +65,9 @@ public class LifecycleModuleBuilder
@Requirement
private List<ProjectExecutionListener> projectExecutionListeners;

@Requirement
private SessionScope sessionScope;

public void setProjectExecutionListeners( final List<ProjectExecutionListener> listeners )
{
this.projectExecutionListeners = listeners;
Expand All @@ -83,6 +87,10 @@ public void buildProject( MavenSession session, MavenSession rootSession, Reacto

long buildStartTime = System.currentTimeMillis();

// session may be different from rootSession seeded in DefaultMaven
// explicitly seed the right session here to make sure it is used by Guice
sessionScope.enter();
sessionScope.seed( MavenSession.class, session );
try
{

Expand Down Expand Up @@ -125,6 +133,8 @@ public void buildProject( MavenSession session, MavenSession rootSession, Reacto
}
finally
{
sessionScope.exit();

session.setCurrentProject( null );

Thread.currentThread().setContextClassLoader( reactorContext.getOriginalContextClassLoader() );
Expand Down

0 comments on commit 702acd2

Please sign in to comment.