Skip to content

Commit 2644af5

Browse files
o Updated to guard against 'NullPointerException's.
Fixes #1
1 parent ba1c194 commit 2644af5

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/main/java/org/codehaus/plexus/util/AbstractScanner.java

+16-6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919

2020
import java.io.File;
21+
import java.util.ArrayList;
22+
import java.util.List;
2123

2224
/**
2325
* Scan a directory tree for files, with specified inclusions and exclusions.
@@ -262,11 +264,15 @@ public void setIncludes( String[] includes )
262264
}
263265
else
264266
{
265-
this.includes = new String[includes.length];
266-
for ( int i = 0; i < includes.length; i++ )
267+
final List<String> list = new ArrayList<String>( includes.length );
268+
for ( String include : includes )
267269
{
268-
this.includes[i] = normalizePattern( includes[i] );
270+
if ( include != null )
271+
{
272+
list.add( normalizePattern( include ) );
273+
}
269274
}
275+
this.includes = list.toArray( new String[ list.size() ] );
270276
}
271277
}
272278

@@ -290,11 +296,15 @@ public void setExcludes( String[] excludes )
290296
}
291297
else
292298
{
293-
this.excludes = new String[excludes.length];
294-
for ( int i = 0; i < excludes.length; i++ )
299+
final List<String> list = new ArrayList<String>( excludes.length );
300+
for ( String exclude : excludes )
295301
{
296-
this.excludes[i] = normalizePattern( excludes[i] );
302+
if ( exclude != null )
303+
{
304+
list.add( normalizePattern( exclude ) );
305+
}
297306
}
307+
this.excludes = list.toArray( new String[ list.size() ] );
298308
}
299309
}
300310

0 commit comments

Comments
 (0)