continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r793475 - in /continuum/branches/continuum-1.3.x/continuum-core/src: main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java
Date Mon, 13 Jul 2009 07:37:50 GMT
Author: ctan
Date: Mon Jul 13 07:37:50 2009
New Revision: 793475

URL: http://svn.apache.org/viewvc?rev=793475&view=rev
Log:
[CONTINUUM-2295] 
- more on prevent NPE when scm result is null
- added unit test

Modified:
    continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
    continuum/branches/continuum-1.3.x/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java

Modified: continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java?rev=793475&r1=793474&r2=793475&view=diff
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
(original)
+++ continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
Mon Jul 13 07:37:50 2009
@@ -481,11 +481,14 @@
             project.getState() != ContinuumProjectState.NEW && project.getState()
!= ContinuumProjectState.CHECKEDOUT )
         {
             // Check SCM changes
-            allChangesUnknown = checkAllChangesUnknown( context.getScmResult().getChanges()
);
+            if ( context.getScmResult() != null )
+            {
+                allChangesUnknown = checkAllChangesUnknown( context.getScmResult().getChanges()
);
+            }
 
             if ( allChangesUnknown )
             {
-                if ( !context.getScmResult().getChanges().isEmpty() )
+                if ( context.getScmResult() != null && !context.getScmResult().getChanges().isEmpty()
)
                 {
                     log.info(
                         "The project was not built because all changes are unknown (maybe
local modifications or ignored files not defined in your SCM tool." );
@@ -506,14 +509,19 @@
         }
 
         // Check changes
-        if ( !shouldBuild && ( ( !allChangesUnknown && !context.getScmResult().getChanges().isEmpty()
) ||
+        if ( !shouldBuild && ( ( !allChangesUnknown && context.getScmResult()
!= null && !context.getScmResult().getChanges().isEmpty() ) ||
             project.getExecutorId().equals( ContinuumBuildExecutorConstants.MAVEN_TWO_BUILD_EXECUTOR
) ) )
         {
             try
             {
                 ContinuumBuildExecutor executor = buildExecutorManager.getBuildExecutor(
project.getExecutorId() );
 
-                if ( context.getScmResult() != null )
+                if ( executor == null )
+                {
+                    log.warn( "No continuum build executor found for project " + project.getId()
+ 
+                              " with executor '" + project.getExecutorId() + "'" );
+                }
+                else if ( context.getScmResult() != null )
                 {
                     shouldBuild = executor.shouldBuild( context.getScmResult().getChanges(),
project,
                                                         workingDirectoryService.getWorkingDirectory(
project ),

Modified: continuum/branches/continuum-1.3.x/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java?rev=793475&r1=793474&r2=793475&view=diff
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java
(original)
+++ continuum/branches/continuum-1.3.x/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java
Mon Jul 13 07:37:50 2009
@@ -184,6 +184,16 @@
         assertTrue( controller.shouldBuild( context ) );
     }
 
+    public void testWithNullScmResult()
+        throws Exception
+    {
+        BuildContext context = getContext( +1 );
+        context.setScmResult( null );
+        controller.checkProjectDependencies( context );
+        assertEquals( 0, context.getModifiedDependencies().size() );
+        assertFalse( controller.shouldBuild( context ) );
+    }
+
     private File getWorkingDirectory()
         throws Exception
     {



Mime
View raw message