Applied patch (FELIX-577) to improve handling of improper resource URLs.


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@682431 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java b/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java
index 88e5ea8..add726c 100644
--- a/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java
+++ b/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java
@@ -72,11 +72,16 @@
         }
         int revision = Util.getModuleRevisionFromModuleId(url.getHost());
         IModule[] modules = bundle.getInfo().getModules();
-        if ((modules == null) || (revision < 0) || (revision >= modules.length))
+        if ((modules == null) || (revision >= modules.length))
         {
             throw new IOException("Resource does not exist: " + url);
         }
 
+        // If the revision is not specified, check the latest
+        if (revision < 0)
+        {
+            revision = modules.length - 1;
+        }
         // If the resource cannot be found at the current class path index,
         // then search them all in order to see if it can be found. This is
         // necessary since the user might create a resource URL from another
@@ -86,6 +91,10 @@
         // one on the class path.
         m_targetModule = modules[revision];
         m_classPathIdx = url.getPort();
+        if (m_classPathIdx < 0)
+        {
+            m_classPathIdx = 0;
+        }
         if (!modules[revision].getContentLoader().hasInputStream(m_classPathIdx, url.getPath()))
         {
             URL newurl = modules[revision].getContentLoader().getResource(url.getPath());
diff --git a/framework/src/main/java/org/apache/felix/framework/util/Util.java b/framework/src/main/java/org/apache/felix/framework/util/Util.java
index 5446dc7..35c2fa9 100644
--- a/framework/src/main/java/org/apache/felix/framework/util/Util.java
+++ b/framework/src/main/java/org/apache/felix/framework/util/Util.java
@@ -55,14 +55,16 @@
     {
         try
         {
-            String rev = (id.indexOf('.') >= 0)
-                ? id.substring(id.indexOf('.') + 1) : id;
-            return Integer.parseInt(rev);
+            int index = id.indexOf('.');
+            if (index >= 0)
+            {
+                return Integer.parseInt(id.substring(index + 1));
+            }
         }
         catch (NumberFormatException ex)
         {
-            return -1;
         }
+        return -1;
     }
 
     public static String getClassName(String className)