Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVioleta Georgieva2017-01-11 09:30:23 +0000
committerVioleta Georgieva2017-01-11 09:30:23 +0000
commit638997a466c9140fcbd574e04f3bbaad76522f47 (patch)
tree3f1e90c3c00989a67e17bf511ef24855a9af1001
parent363855be6d423778448cd6fb6ba9a465ae9bffa6 (diff)
downloadorg.eclipse.gemini.web.gemini-web-container-638997a466c9140fcbd574e04f3bbaad76522f47.tar.gz
org.eclipse.gemini.web.gemini-web-container-638997a466c9140fcbd574e04f3bbaad76522f47.tar.xz
org.eclipse.gemini.web.gemini-web-container-638997a466c9140fcbd574e04f3bbaad76522f47.zip
Bug 509502: Ensure bundle location is resolved correctly when EquinoxBundleFileResolver cannot be used.
-rw-r--r--org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/BundleDependenciesJarScanner.java26
-rw-r--r--org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/BundleDependenciesJarScannerTests.java15
2 files changed, 11 insertions, 30 deletions
diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/BundleDependenciesJarScanner.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/BundleDependenciesJarScanner.java
index 334cbae..c38390f 100644
--- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/BundleDependenciesJarScanner.java
+++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/BundleDependenciesJarScanner.java
@@ -19,8 +19,6 @@ package org.eclipse.gemini.web.tomcat.internal;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
import java.net.URL;
import java.util.Set;
@@ -60,8 +58,6 @@ final class BundleDependenciesJarScanner implements JarScanner {
private static final String JAR_URL_PREFIX = "jar:";
- private static final String REFERENCE_URL_PREFIX = "reference";
-
private static final Logger LOGGER = LoggerFactory.getLogger(BundleDependenciesJarScanner.class);
private final BundleDependencyDeterminer bundleDependencyDeterminer;
@@ -127,31 +123,17 @@ final class BundleDependenciesJarScanner implements JarScanner {
private void scanJarUrlConnection(Bundle bundle, JarScannerCallback callback, boolean isWebapp) {
URL bundleUrl;
- String bundleLocation = bundle.getLocation();
+ URL root = bundle.getEntry("/");
try {
- bundleUrl = new URL(bundleLocation);
- if (REFERENCE_URL_PREFIX.equals(bundleUrl.getProtocol())) {
- bundleUrl = new URL(JAR_URL_PREFIX + transformBundleLocation(bundleUrl.getFile()) + JAR_URL_SUFFIX);
- } else {
- bundleUrl = new URL(JAR_URL_PREFIX + transformBundleLocation(bundleLocation) + JAR_URL_SUFFIX);
- }
- } catch (MalformedURLException | URISyntaxException e) {
- LOGGER.warn("Failed to create jar: url for bundle location [" + bundleLocation + "].");
+ bundleUrl = new URL(JAR_URL_PREFIX + root.toExternalForm() + JAR_URL_SUFFIX);
+ } catch (MalformedURLException e) {
+ LOGGER.warn("Failed to create jar: url for bundle location [" + root + "].");
return;
}
scanBundleUrl(bundleUrl, callback, isWebapp);
}
- private String transformBundleLocation(String location) throws URISyntaxException {
- URI url = new URI(location);
- if (!url.isOpaque()) {
- return location;
- }
- String scheme = url.getScheme();
- return scheme + ":/" + location.substring(scheme.length() + 1);
- }
-
private void scanBundleFile(File bundleFile, JarScannerCallback callback, boolean isWebapp) {
if (bundleFile.isDirectory()) {
try {
diff --git a/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/BundleDependenciesJarScannerTests.java b/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/BundleDependenciesJarScannerTests.java
index 1cb734f..bb2c071 100644
--- a/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/BundleDependenciesJarScannerTests.java
+++ b/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/BundleDependenciesJarScannerTests.java
@@ -27,6 +27,7 @@ import static org.easymock.EasyMock.verify;
import java.io.File;
import java.io.IOException;
+import java.net.URL;
import java.net.URLClassLoader;
import java.util.Arrays;
import java.util.Collections;
@@ -124,23 +125,21 @@ public class BundleDependenciesJarScannerTests {
@Test
public void scanJarUrlConnection() throws IOException {
- expect(this.dependencyDeterminer.getDependencies(this.bundle)).andReturn(new HashSet<>(Arrays.asList(this.dependency))).times(2);
- String bundleLocation = new File("./src/test/resources/bundle.jar").toURI().toString();
- expect(this.dependency.getLocation()).andReturn(bundleLocation).andReturn("reference:" + bundleLocation);
- expect(this.dependency.getSymbolicName()).andReturn("bundle").anyTimes();
+ expect(this.dependencyDeterminer.getDependencies(this.bundle)).andReturn(new HashSet<>(Arrays.asList(this.dependency)));
+ URL bundleLocation = new File("./src/test/resources/bundle.jar").toURI().toURL();
+ expect(this.dependency.getEntry("/")).andReturn(bundleLocation);
+ expect(this.dependency.getSymbolicName()).andReturn("bundle");
- expect(this.bundleFileResolver.resolve(this.dependency)).andReturn(null).times(2);
+ expect(this.bundleFileResolver.resolve(this.dependency)).andReturn(null);
this.callback.scan(isA(Jar.class), (String) isNull(), eq(true));
ClassLoader classLoader = new BundleWebappClassLoader(this.bundle, this.classLoaderCustomizer);
- expect(this.servletContext.getClassLoader()).andReturn(classLoader).times(2);
+ expect(this.servletContext.getClassLoader()).andReturn(classLoader);
replay(this.dependencyDeterminer, this.bundleFileResolver, this.callback, this.dependency, this.servletContext);
this.scanner.scan(null, this.servletContext, this.callback);
- this.scanner.scan(null, this.servletContext, this.callback);
-
((URLClassLoader) classLoader).close();
verify(this.dependencyDeterminer, this.bundleFileResolver, this.callback, this.dependency, this.servletContext);

Back to the top