click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r791922 - /incubator/click/trunk/click/framework/src/org/apache/click/service/ClickResourceService.java
Date Tue, 07 Jul 2009 17:57:54 GMT
Author: sabob
Date: Tue Jul  7 17:57:54 2009
New Revision: 791922

URL: http://svn.apache.org/viewvc?rev=791922&view=rev
Log:
fixed couple of NPE

Modified:
    incubator/click/trunk/click/framework/src/org/apache/click/service/ClickResourceService.java

Modified: incubator/click/trunk/click/framework/src/org/apache/click/service/ClickResourceService.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/service/ClickResourceService.java?rev=791922&r1=791921&r2=791922&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/service/ClickResourceService.java
(original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/service/ClickResourceService.java
Tue Jul  7 17:57:54 2009
@@ -156,6 +156,12 @@
             // from jar
             boolean logFeedback = true;
             while ((jarEntry = jarInputStream.getNextJarEntry()) != null) {
+
+                // Guard against loading folders -> META-INF/web/click/
+                if (jarEntry.isDirectory()) {
+                    continue;
+                }
+
                 // jarEntryName example -> META-INF/web/click/table.css
                 String jarEntryName = jarEntry.getName();
 
@@ -198,6 +204,12 @@
         while (files.hasNext()) {
             // file example -> META-INF/web/click/table.css
             File file = (File) files.next();
+
+            // Guard against loading folders -> META-INF/web/click/
+            if (file.isDirectory()) {
+                continue;
+            }
+
             String fileName = file.getCanonicalPath().replace('\\', '/');
 
             // Only deploy resources from "META-INF/web/"
@@ -259,24 +271,26 @@
 
         Set resources = servletContext.getResourcePaths("/click/");
 
-        // Add all resources withtin web application
-        for (Iterator i = resources.iterator(); i.hasNext();) {
-            String resource = (String) i.next();
+        if (resources != null) {
+            // Add all resources withtin web application
+            for (Iterator i = resources.iterator(); i.hasNext();) {
+                String resource = (String) i.next();
 
-            if (!resource.endsWith(".htm")
-                && !resource.endsWith(".jsp")
-                && !resource.endsWith("/")) {
+                if (!resource.endsWith(".htm") && !resource.endsWith(".jsp")
+                    && !resource.endsWith("/")) {
 
-                InputStream inputStream = null;
-                try {
-                    inputStream = servletContext.getResourceAsStream(resource);
+                    InputStream inputStream = null;
+                    try {
+                        inputStream = servletContext.getResourceAsStream(
+                            resource);
 
-                    byte[] resourceData = IOUtils.toByteArray(inputStream);
+                        byte[] resourceData = IOUtils.toByteArray(inputStream);
 
-                     resourceCache.put(resource, resourceData);
+                        resourceCache.put(resource, resourceData);
 
-                } finally {
-                    ClickUtils.close(inputStream);
+                    } finally {
+                        ClickUtils.close(inputStream);
+                    }
                 }
             }
         }



Mime
View raw message