You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ag...@apache.org on 2013/03/28 22:38:01 UTC

git commit: [SUREFIRE-980] avoid NPE on empty include/exclude tags

Updated Branches:
  refs/heads/master becadaf1f -> 8cb7ab468


[SUREFIRE-980] avoid NPE on empty include/exclude tags


Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/8cb7ab46
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/8cb7ab46
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/8cb7ab46

Branch: refs/heads/master
Commit: 8cb7ab468538b7aad41ad713b6890048e854c794
Parents: becadaf
Author: Andreas Gudian <ag...@apache.org>
Authored: Thu Mar 28 22:36:10 2013 +0100
Committer: Andreas Gudian <ag...@apache.org>
Committed: Thu Mar 28 22:36:10 2013 +0100

----------------------------------------------------------------------
 .../plugin/surefire/AbstractSurefireMojo.java      |   22 ++++++++++++---
 .../src/test/resources/includes-excludes/pom.xml   |    2 +
 2 files changed, 20 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/8cb7ab46/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index bb88358..2ff2c58 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -1230,10 +1230,10 @@ public abstract class AbstractSurefireMojo
             // Have to wrap in an ArrayList as surefire expects an ArrayList instead of a List for some reason
             if ( excludes == null || excludes.size() == 0 )
             {
-                excludes = new ArrayList<String>( Arrays.asList( new String[]{ "**/*$*" } ) );
+                excludes = Arrays.asList( new String[]{ "**/*$*" } );
             }
         }
-        return excludes;
+        return filterNulls( excludes );
     }
 
     private List<String> getIncludeList()
@@ -1265,10 +1265,24 @@ public abstract class AbstractSurefireMojo
         // Have to wrap in an ArrayList as surefire expects an ArrayList instead of a List for some reason
         if ( includes == null || includes.size() == 0 )
         {
-            includes = new ArrayList<String>( Arrays.asList( getDefaultIncludes() ) );
+            includes = Arrays.asList( getDefaultIncludes() );
+        }
+
+        return filterNulls( includes );
+    }
+
+    private List<String> filterNulls( List<String> toFilter )
+    {
+        List<String> result = new ArrayList<String>( toFilter.size() );
+        for ( String item : toFilter )
+        {
+            if ( item != null )
+            {
+                result.add( item );
+            }
         }
 
-        return includes;
+        return result;
     }
 
     private boolean isMultipleExecutionBlocksDetected()

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/8cb7ab46/surefire-integration-tests/src/test/resources/includes-excludes/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/includes-excludes/pom.xml b/surefire-integration-tests/src/test/resources/includes-excludes/pom.xml
index e6a831b..504171e 100644
--- a/surefire-integration-tests/src/test/resources/includes-excludes/pom.xml
+++ b/surefire-integration-tests/src/test/resources/includes-excludes/pom.xml
@@ -64,6 +64,8 @@ under the License.
             <configuration>
               <excludes>
                 <exclude>**/DontRunTest.*</exclude>
+                <exclude></exclude>
+                <exclude />
               </excludes>
               <includes>
                 <include>**/NotIncludedByDefault.java</include>