You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2009/06/17 17:13:16 UTC

svn commit: r785652 - in /felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall: DirectoryWatcher.java Jar.java

Author: rickhall
Date: Wed Jun 17 15:13:16 2009
New Revision: 785652

URL: http://svn.apache.org/viewvc?rev=785652&view=rev
Log:
Apply patch (FELIX-1228) to allow spaces in file names.

Modified:
    felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/DirectoryWatcher.java
    felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/Jar.java

Modified: felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/DirectoryWatcher.java
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/DirectoryWatcher.java?rev=785652&r1=785651&r2=785652&view=diff
==============================================================================
--- felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/DirectoryWatcher.java (original)
+++ felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/DirectoryWatcher.java Wed Jun 17 15:13:16 2009
@@ -552,20 +552,20 @@
         {
             try
             {
-                final URI uri = new URI(bundles[i].getLocation());
-                if (uri.isOpaque())
+                Jar jar = new Jar(bundles[i]);
+                String path =  jar.getPath();
+                if (path == null)
                 {
-                    // We can't do any meaningful processing of Opaque URI.
-                    // e.g. Path component of an opaque URI is null
+                    // jar.getPath is null means we could not parse the location
+                    // as a meaningful URI or file path. e.g., location
+                    // represented an Opaque URI.
+                    // We can't do any meaningful processing for this bundle.
                     continue;
                 }
-                String location =  uri.normalize().getPath();
-                final int index = location.lastIndexOf('/');
-                if (index != -1 && location.substring(0, index + 1).equals(watchedDirPath))
+                final int index = path.lastIndexOf('/');
+                if (index != -1 && path.substring(0, index + 1).equals(watchedDirPath))
                 {
-                    // This bundle's location matches our watched dir path
-                    Jar jar = new Jar(bundles[i]);
-                    currentManagedBundles.put(jar.getPath(), jar);
+                    currentManagedBundles.put(path, jar);
                 }
             }
             catch (URISyntaxException e)

Modified: felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/Jar.java
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/Jar.java?rev=785652&r1=785651&r2=785652&view=diff
==============================================================================
--- felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/Jar.java (original)
+++ felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/Jar.java Wed Jun 17 15:13:16 2009
@@ -28,7 +28,7 @@
  * This class is used to cache vital information of a jar file
  * that is used during later processing. It also overrides hashCode and
  * equals methods so that it can be used in various Set operations.
- * It uses file's path as the primary key. Before
+ * It uses file's path as the primary key. 
  *
  * @author Sanjeeb.Sahoo@Sun.COM
  */
@@ -53,10 +53,26 @@
 
     Jar(Bundle b) throws URISyntaxException
     {
+        // Convert to a URI because the location of a bundle
+        // is typically a URI. At least, that's the case for
+        // autostart bundles.
         // Normalisation is needed to ensure that we don't treat (e.g.)
         // /tmp/foo and /tmp//foo differently.
-        URI uri = new URI(b.getLocation()).normalize();
-        path = uri.getPath();
+        String location = b.getLocation();
+        if (location != null)
+        {
+            URI uri;
+            try
+            {
+                uri = new URI(b.getLocation()).normalize();
+            }
+            catch (URISyntaxException e)
+            {
+                // Let's try to interpret the location as a file path
+                uri = new File(location).toURI().normalize();
+            }
+            path = uri.getPath();
+        }
         lastModified = b.getLastModified();
         bundleId = b.getBundleId();
     }