Embedded JAR files are now cached with their full path information to
avoid the possibility of name clashes.
This will cause backwards compatibility issues with old profiles. To
remedy the issue either recreate the profile or simply perform an 'update'
on any impacted bundle.
git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@375557 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/DefaultBundleArchive.java b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/DefaultBundleArchive.java
index 101f067..f73a294 100644
--- a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/DefaultBundleArchive.java
+++ b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/DefaultBundleArchive.java
@@ -833,10 +833,7 @@
}
else
{
- String jarName = (classPathStrings[i].lastIndexOf('/') >= 0)
- ? classPathStrings[i].substring(classPathStrings[i].lastIndexOf('/') + 1)
- : classPathStrings[i];
- classPath[i] = new JarContent(new File(embedDir, jarName));
+ classPath[i] = new JarContent(new File(embedDir, classPathStrings[i]));
}
}
@@ -1185,18 +1182,26 @@
{
// Remove leading slash if present.
jarPath = (jarPath.charAt(0) == '/') ? jarPath.substring(1) : jarPath;
- // Get only the JAR file name.
-// TODO: FIX THIS SO THAT IT CREATES DIRECTORIES TO AVOID NAME CLASHES,
-// DOING SO WILL IMPACT getContentLoaderUnchecked() METHOD ABOVE.
- String jarName = (jarPath.lastIndexOf('/') >= 0)
- ? jarPath.substring(jarPath.lastIndexOf('/') + 1) : jarPath;
// If JAR is already extracted, then don't
// re-extract it...
File embedFile = new File(
- revisionDir, EMBEDDED_DIRECTORY + File.separatorChar + jarName);
+ revisionDir, EMBEDDED_DIRECTORY + File.separatorChar + jarPath);
+
if (!embedFile.exists())
{
+ // Make sure that the embedded JAR's parent directory exists;
+ // it may be in a sub-directory.
+ File embedDir = embedFile.getParentFile();
+ if (!embedDir.exists())
+ {
+ if (!embedDir.mkdirs())
+ {
+ throw new IOException("Unable to create embedded JAR directory.");
+ }
+ }
+
+ // Extract embedded JAR into its directory.
JarFile jarFile = null;
InputStream is = null;