[MNG-5456] Incorrect exception handling in parallel build

This commit is contained in:
Kristian Rosenvold 2013-03-30 07:00:05 +01:00
parent eb164f514c
commit 973673721b
2 changed files with 18 additions and 15 deletions

View File

@ -171,16 +171,16 @@ public class DefaultMaven
} }
catch ( OutOfMemoryError e ) catch ( OutOfMemoryError e )
{ {
result = processResult( new DefaultMavenExecutionResult(), e ); result = addExceptionToResult(new DefaultMavenExecutionResult(), e);
} }
catch ( MavenExecutionRequestPopulationException e ) catch ( MavenExecutionRequestPopulationException e )
{ {
result = processResult( new DefaultMavenExecutionResult(), e ); result = addExceptionToResult(new DefaultMavenExecutionResult(), e);
} }
catch ( RuntimeException e ) catch ( RuntimeException e )
{ {
result = result =
processResult( new DefaultMavenExecutionResult(), addExceptionToResult(new DefaultMavenExecutionResult(),
new InternalErrorException("Internal error: " + e, e)); new InternalErrorException("Internal error: " + e, e));
} }
finally finally
@ -211,7 +211,7 @@ public class DefaultMaven
} }
catch ( LocalRepositoryNotAccessibleException e ) catch ( LocalRepositoryNotAccessibleException e )
{ {
return processResult( result, e ); return addExceptionToResult(result, e);
} }
DelegatingLocalArtifactRepository delegatingLocalArtifactRepository = DelegatingLocalArtifactRepository delegatingLocalArtifactRepository =
@ -233,7 +233,7 @@ public class DefaultMaven
} }
catch ( MavenExecutionException e ) catch ( MavenExecutionException e )
{ {
return processResult( result, e ); return addExceptionToResult(result, e);
} }
eventCatapult.fire( ExecutionEvent.Type.ProjectDiscoveryStarted, session, null ); eventCatapult.fire( ExecutionEvent.Type.ProjectDiscoveryStarted, session, null );
@ -249,7 +249,7 @@ public class DefaultMaven
} }
catch ( ProjectBuildingException e ) catch ( ProjectBuildingException e )
{ {
return processResult( result, e ); return addExceptionToResult(result, e);
} }
session.setProjects( projects ); session.setProjects( projects );
@ -275,7 +275,7 @@ public class DefaultMaven
} }
catch ( org.apache.maven.DuplicateProjectException e ) catch ( org.apache.maven.DuplicateProjectException e )
{ {
return processResult( result, e ); return addExceptionToResult(result, e);
} }
repoSession.setReadOnly(); repoSession.setReadOnly();
@ -292,7 +292,7 @@ public class DefaultMaven
} }
catch ( MavenExecutionException e ) catch ( MavenExecutionException e )
{ {
return processResult( result, e ); return addExceptionToResult(result, e);
} }
finally finally
{ {
@ -315,15 +315,15 @@ public class DefaultMaven
ProjectCycleException error = new ProjectCycleException( message, e ); ProjectCycleException error = new ProjectCycleException( message, e );
return processResult( result, error ); return addExceptionToResult(result, error);
} }
catch ( DuplicateProjectException e ) catch ( DuplicateProjectException e )
{ {
return processResult( result, e ); return addExceptionToResult(result, e);
} }
catch ( MavenExecutionException e ) catch ( MavenExecutionException e )
{ {
return processResult( result, e ); return addExceptionToResult(result, e);
} }
result.setTopologicallySortedProjects( session.getProjects() ); result.setTopologicallySortedProjects( session.getProjects() );
@ -339,7 +339,7 @@ public class DefaultMaven
if ( session.getResult().hasExceptions() ) if ( session.getResult().hasExceptions() )
{ {
return processResult( result, session.getResult().getExceptions().get( 0 ) ); return addExceptionToResult(result, session.getResult().getExceptions().get(0));
} }
return result; return result;
@ -592,7 +592,7 @@ public class DefaultMaven
return lifecycleListeners; return lifecycleListeners;
} }
private MavenExecutionResult processResult( MavenExecutionResult result, Throwable e ) private MavenExecutionResult addExceptionToResult(MavenExecutionResult result, Throwable e)
{ {
if ( !result.getExceptions().contains( e ) ) if ( !result.getExceptions().contains( e ) )
{ {

View File

@ -78,7 +78,8 @@ public class LifecycleThreadedBuilder
} }
catch ( Exception e ) catch ( Exception e )
{ {
break; // Why are we just ignoring this exception? Are exceptions are being used for flow control session.getResult().addException(e);
break;
} }
} }
@ -125,10 +126,12 @@ public class LifecycleThreadedBuilder
} }
catch ( InterruptedException e ) catch ( InterruptedException e )
{ {
rootSession.getResult().addException(e);
break; break;
} }
catch ( ExecutionException e ) catch ( ExecutionException e )
{ {
rootSession.getResult().addException(e);
break; break;
} }
} }