felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r682431 - in /felix/trunk/framework/src/main/java/org/apache/felix/framework: URLHandlersBundleURLConnection.java util/Util.java
Date Mon, 04 Aug 2008 15:58:21 GMT
Author: rickhall
Date: Mon Aug  4 08:58:21 2008
New Revision: 682431

URL: http://svn.apache.org/viewvc?rev=682431&view=rev
Log:
Applied patch (FELIX-577) to improve handling of improper resource URLs.

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/Util.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java?rev=682431&r1=682430&r2=682431&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java
Mon Aug  4 08:58:21 2008
@@ -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());

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/util/Util.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/util/Util.java?rev=682431&r1=682430&r2=682431&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/util/Util.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/util/Util.java Mon Aug
 4 08:58:21 2008
@@ -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)



Mime
View raw message