]> source.dussan.org Git - gitblit.git/commitdiff
Handle possible NPE when extracting WAR resources into a new directory
authorJames Moger <james.moger@gitblit.com>
Wed, 25 Nov 2015 13:50:10 +0000 (08:50 -0500)
committerJames Moger <james.moger@gitblit.com>
Wed, 25 Nov 2015 13:50:10 +0000 (08:50 -0500)
src/main/java/com/gitblit/servlet/GitblitContext.java

index fb8f6b9dad763cdb6b566a4b96ac38ca3aef35f5..750da796f33c1398a2d10acf047bcd93eb0da3fb 100644 (file)
@@ -24,6 +24,7 @@ import java.io.OutputStream;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
 
 import javax.naming.Context;
 import javax.naming.InitialContext;
@@ -455,7 +456,12 @@ public class GitblitContext extends GuiceServletContextListener {
        }
 
        protected void extractResources(ServletContext context, String path, File toDir) {
-               for (String resource : context.getResourcePaths(path)) {
+               Set<String> resources = context.getResourcePaths(path);
+               if (resources == null) {
+                       logger.warn("There are no WAR resources to extract from {}", path);
+                       return;
+               }
+               for (String resource : resources) {
                        // extract the resource to the directory if it does not exist
                        File f = new File(toDir, resource.substring(path.length()));
                        if (!f.exists()) {