You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ke...@apache.org on 2006/09/02 15:36:59 UTC
svn commit: r439592 -
/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
Author: kenney
Date: Sat Sep 2 06:36:59 2006
New Revision: 439592
URL: http://svn.apache.org/viewvc?rev=439592&view=rev
Log:
Fix NPE when an error occurs before a buildResult is created (for instance
when SCM action fails)
Modified:
maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java?rev=439592&r1=439591&r2=439592&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java Sat Sep 2 06:36:59 2006
@@ -74,8 +74,10 @@
// ----------------------------------------------------------------------
/**
+ * @param projectId
+ * @param buildDefinitionId
+ * @param trigger
* @throws TaskExecutionException
- * @todo structure of this method is a bit of a mess (too much exception/finally code)
*/
public void build( int projectId, int buildDefinitionId, int trigger )
throws TaskExecutionException
@@ -150,8 +152,7 @@
}
/**
- * Checks if the build should be marked as ERROR and notifies
- * the end of the build.
+ * Checks if the build should be marked as ERROR and notifies the end of the build.
*
* @param context
* @throws TaskExecutionException
@@ -187,17 +188,25 @@
{
BuildResult build = context.getBuildResult();
- build.setError( error );
-
- try
+ if ( build == null )
{
- store.updateBuildResult( build );
-
- build = store.getBuildResult( build.getId() );
+ build = makeAndStoreBuildResult( context, error );
}
- catch ( ContinuumStoreException e )
+ else
{
- throw new TaskExecutionException( "Error updating build result", e );
+
+ build.setError( error );
+
+ try
+ {
+ store.updateBuildResult( build );
+
+ build = store.getBuildResult( build.getId() );
+ }
+ catch ( ContinuumStoreException e )
+ {
+ throw new TaskExecutionException( "Error updating build result", e );
+ }
}
context.getProject().setState( build.getState() );
@@ -292,8 +301,7 @@
actionContext.put( AbstractContinuumAction.KEY_TRIGGER, new Integer( trigger ) );
- actionContext
- .put( AbstractContinuumAction.KEY_FIRST_RUN, Boolean.valueOf( context.getOldBuildResult() == null ) );
+ actionContext.put( AbstractContinuumAction.KEY_FIRST_RUN, Boolean.valueOf( context.getOldBuildResult() == null ) );
return context;
}
@@ -305,8 +313,8 @@
performAction( "check-working-directory", buildContext );
- boolean workingDirectoryExists = AbstractContinuumAction
- .getBoolean( actionContext, AbstractContinuumAction.KEY_WORKING_DIRECTORY_EXISTS );
+ boolean workingDirectoryExists = AbstractContinuumAction.getBoolean( actionContext,
+ AbstractContinuumAction.KEY_WORKING_DIRECTORY_EXISTS );
ScmResult scmResult;
@@ -320,8 +328,8 @@
{
Project project = (Project) actionContext.get( AbstractContinuumAction.KEY_PROJECT );
- actionContext.put( AbstractContinuumAction.KEY_WORKING_DIRECTORY, workingDirectoryService
- .getWorkingDirectory( project ).getAbsolutePath() );
+ actionContext.put( AbstractContinuumAction.KEY_WORKING_DIRECTORY,
+ workingDirectoryService.getWorkingDirectory( project ).getAbsolutePath() );
performAction( "checkout-project", buildContext );
@@ -391,9 +399,9 @@
private boolean shouldBuild( BuildContext context )
throws TaskExecutionException
{
- //oldBuildResult != null &&
- // List changes, Project project, int trigger )
- // scmResult.getChanges(), project, trigger ) )
+ // oldBuildResult != null &&
+ // List changes, Project project, int trigger )
+ // scmResult.getChanges(), project, trigger ) )
boolean allChangesUnknown = checkAllChangesUnknown( context.getScmResult().getChanges() );
@@ -506,8 +514,8 @@
private BuildResult makeAndStoreBuildResult( BuildContext context, String error )
throws TaskExecutionException
{
- // Project project, ScmResult scmResult, long startTime, int trigger )
- // project, scmResult, startTime, trigger );
+ // Project project, ScmResult scmResult, long startTime, int trigger )
+ // project, scmResult, startTime, trigger );
BuildResult build = new BuildResult();
@@ -585,7 +593,7 @@
}
/**
- * Merges scm results so we'll have all changes since last execution of current build definition
+ * Merges scm results so we'll have all changes since last execution of current build definition
*/
private void mergeScmResults( BuildContext context )
{