Skip to content

Commit d1eb00e

Browse files
committed
Handle possible NPE when extracting WAR resources into a new directory
1 parent 1aec176 commit d1eb00e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/java/com/gitblit/servlet/GitblitContext.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.text.MessageFormat;
2525
import java.util.ArrayList;
2626
import java.util.List;
27+
import java.util.Set;
2728

2829
import javax.naming.Context;
2930
import javax.naming.InitialContext;
@@ -455,7 +456,12 @@ private File configureExpress(
455456
}
456457

457458
protected void extractResources(ServletContext context, String path, File toDir) {
458-
for (String resource : context.getResourcePaths(path)) {
459+
Set<String> resources = context.getResourcePaths(path);
460+
if (resources == null) {
461+
logger.warn("There are no WAR resources to extract from {}", path);
462+
return;
463+
}
464+
for (String resource : resources) {
459465
// extract the resource to the directory if it does not exist
460466
File f = new File(toDir, resource.substring(path.length()));
461467
if (!f.exists()) {

0 commit comments

Comments
 (0)