Skip to content

Commit f9bbaff

Browse files
committed
Avoid NPE if initialization of theJar failed silently in init(). Related to MCHECKSTYLE-250 and MCHECKSTYLE-288.
1 parent 93b15b6 commit f9bbaff

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/main/java/org/codehaus/plexus/resource/loader/JarHolder.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,19 @@ public Hashtable getEntries()
123123
{
124124
Hashtable allEntries = new Hashtable( 559 );
125125

126-
Enumeration all = theJar.entries();
127-
128-
while ( all.hasMoreElements() )
126+
if ( theJar != null )
129127
{
130-
JarEntry je = (JarEntry) all.nextElement();
128+
Enumeration all = theJar.entries();
131129

132-
// We don't map plain directory entries
133-
if ( !je.isDirectory() )
130+
while ( all.hasMoreElements() )
134131
{
135-
allEntries.put( je.getName(), this.urlpath );
132+
JarEntry je = (JarEntry) all.nextElement();
133+
134+
// We don't map plain directory entries
135+
if ( !je.isDirectory() )
136+
{
137+
allEntries.put( je.getName(), this.urlpath );
138+
}
136139
}
137140
}
138141
return allEntries;

0 commit comments

Comments
 (0)