Apply patch (FELIX-1228) to allow spaces in file names.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@785652 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/fileinstall/src/main/java/org/apache/felix/fileinstall/DirectoryWatcher.java b/fileinstall/src/main/java/org/apache/felix/fileinstall/DirectoryWatcher.java
index 046c954..c0bc3cc 100644
--- a/fileinstall/src/main/java/org/apache/felix/fileinstall/DirectoryWatcher.java
+++ b/fileinstall/src/main/java/org/apache/felix/fileinstall/DirectoryWatcher.java
@@ -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)
diff --git a/fileinstall/src/main/java/org/apache/felix/fileinstall/Jar.java b/fileinstall/src/main/java/org/apache/felix/fileinstall/Jar.java
index a9d1f68..dabf274 100644
--- a/fileinstall/src/main/java/org/apache/felix/fileinstall/Jar.java
+++ b/fileinstall/src/main/java/org/apache/felix/fileinstall/Jar.java
@@ -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();
}