You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2012/09/04 13:11:09 UTC

svn commit: r1380552 - /myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceLocator.java

Author: lofwyr
Date: Tue Sep  4 11:11:09 2012
New Revision: 1380552

URL: http://svn.apache.org/viewvc?rev=1380552&view=rev
Log:
NullPointerException when there is no MANIFEST.MF file. (Found the problem while running tests.)

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceLocator.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceLocator.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceLocator.java?rev=1380552&r1=1380551&r2=1380552&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceLocator.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceLocator.java Tue Sep  4 11:11:09 2012
@@ -34,6 +34,7 @@ import org.xml.sax.SAXException;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
@@ -156,21 +157,26 @@ class ResourceLocator {
               int index = themeUrlStr.indexOf(META_INF_TOBAGO_CONFIG_XML);
               String metaInf = themeUrlStr.substring(0, index) + "META-INF/MANIFEST.MF";
               Properties properties = new Properties();
-              InputStream inputStream = new URL(metaInf).openStream();
+              final URL url = new URL(metaInf);
+              InputStream inputStream = null;
+              String version = null;
               try {
+                inputStream = url.openStream();
                 properties.load(inputStream);
-                String version = properties.getProperty("Implementation-Version");
-                if (version != null) {
-                  theme.setVersion(version);
-                } else {
-                  theme.setVersioned(false);
-                  LOG.error("No Implementation-Version found in Manifest-File for theme: '" + theme.getName()
-                      + "'. Resetting the theme to unversioned. Please correct the Manifest-File.");
-                }
-
+                version = properties.getProperty("Implementation-Version");
+              } catch (FileNotFoundException e) {
+                // may happen (e. g. in tests)
+                LOG.error("No Manifest-File found.");
               } finally {
                 IOUtils.closeQuietly(inputStream);
               }
+              if (version != null) {
+                theme.setVersion(version);
+              } else {
+                theme.setVersioned(false);
+                LOG.error("No Implementation-Version found in Manifest-File for theme: '" + theme.getName()
+                    + "'. Resetting the theme to unversioned. Please correct the Manifest-File.");
+              }
             }
             addThemeResources(resources, themeUrl, theme);
           }