From 2644af5a8a51bbaf2cc307386b81d63069954e46 Mon Sep 17 00:00:00 2001 From: Christian Schulte Date: Sat, 7 May 2016 19:31:50 +0200 Subject: [PATCH] o Updated to guard against 'NullPointerException's. Fixes #1 --- .../codehaus/plexus/util/AbstractScanner.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/codehaus/plexus/util/AbstractScanner.java b/src/main/java/org/codehaus/plexus/util/AbstractScanner.java index 7331eff0..4ab17f3f 100644 --- a/src/main/java/org/codehaus/plexus/util/AbstractScanner.java +++ b/src/main/java/org/codehaus/plexus/util/AbstractScanner.java @@ -18,6 +18,8 @@ import java.io.File; +import java.util.ArrayList; +import java.util.List; /** * Scan a directory tree for files, with specified inclusions and exclusions. @@ -262,11 +264,15 @@ public void setIncludes( String[] includes ) } else { - this.includes = new String[includes.length]; - for ( int i = 0; i < includes.length; i++ ) + final List list = new ArrayList( includes.length ); + for ( String include : includes ) { - this.includes[i] = normalizePattern( includes[i] ); + if ( include != null ) + { + list.add( normalizePattern( include ) ); + } } + this.includes = list.toArray( new String[ list.size() ] ); } } @@ -290,11 +296,15 @@ public void setExcludes( String[] excludes ) } else { - this.excludes = new String[excludes.length]; - for ( int i = 0; i < excludes.length; i++ ) + final List list = new ArrayList( excludes.length ); + for ( String exclude : excludes ) { - this.excludes[i] = normalizePattern( excludes[i] ); + if ( exclude != null ) + { + list.add( normalizePattern( exclude ) ); + } } + this.excludes = list.toArray( new String[ list.size() ] ); } }