Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2017-09-12 18:48:41 +0000
committerThomas Watson2017-09-12 18:59:28 +0000
commit5e4efcea7b2902aedba32aa4b4bf6e8c9895de87 (patch)
treeb077838d0a001a89da85e55896a6856251898cc5
parentd3407df5f1308904b377416619d05591b818b2f6 (diff)
downloadrt.equinox.framework-5e4efcea7b2902aedba32aa4b4bf6e8c9895de87.tar.gz
rt.equinox.framework-5e4efcea7b2902aedba32aa4b4bf6e8c9895de87.tar.xz
rt.equinox.framework-5e4efcea7b2902aedba32aa4b4bf6e8c9895de87.zip
Change-Id: I4001b2ecf85a5bf82bb1b12786c776d22b4b8198 Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rwxr-xr-xbundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java59
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java22
2 files changed, 71 insertions, 10 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
index 3eb8f25d8..198a5f612 100755
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
@@ -22,6 +22,7 @@ import javax.net.SocketFactory;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.core.runtime.adaptor.EclipseStarter;
+import org.eclipse.osgi.framework.util.FilePath;
import org.eclipse.osgi.internal.framework.EquinoxConfiguration;
import org.eclipse.osgi.internal.location.EquinoxLocations;
import org.eclipse.osgi.launch.Equinox;
@@ -29,12 +30,15 @@ import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.service.environment.EnvironmentInfo;
import org.eclipse.osgi.storage.url.reference.Handler;
import org.eclipse.osgi.tests.OSGiTestsActivator;
+import org.eclipse.osgi.tests.security.BaseSecurityTest;
import org.junit.Assert;
import org.osgi.framework.*;
import org.osgi.framework.hooks.resolver.ResolverHook;
import org.osgi.framework.hooks.resolver.ResolverHookFactory;
import org.osgi.framework.hooks.weaving.WeavingHook;
import org.osgi.framework.hooks.weaving.WovenClass;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
import org.osgi.framework.namespace.NativeNamespace;
import org.osgi.framework.wiring.*;
import org.osgi.resource.Capability;
@@ -3128,4 +3132,59 @@ public class SystemBundleTests extends AbstractBundleTests {
}
}
}
+
+ public void testSystemCapabilitiesBug522125() throws URISyntaxException, FileNotFoundException, IOException, BundleException, InterruptedException {
+ String frameworkLocation = OSGiTestsActivator.getContext().getProperty(EquinoxConfiguration.PROP_FRAMEWORK);
+ URI uri = new URI(frameworkLocation);
+ File f = new File(uri);
+ if (!f.isFile()) {
+ Assert.fail("Cannot test when framework location is a directory: " + f.getAbsolutePath());
+ }
+ File testDestination = OSGiTestsActivator.getContext().getDataFile(getName() + ".framework.jar");
+ BaseSecurityTest.copy(new FileInputStream(f), testDestination);
+ FilePath userDir = new FilePath(System.getProperty("user.dir"));
+ FilePath testPath = new FilePath(testDestination);
+ String relative = userDir.makeRelative(testPath);
+ System.out.println(relative);
+ URL relativeURL = new URL("file:" + relative);
+ relativeURL.openStream().close();
+ final ClassLoader osgiClassLoader = getClass().getClassLoader();
+ URLClassLoader cl = new URLClassLoader(new URL[] {relativeURL}) {
+
+ @Override
+ protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
+ if (name.startsWith("org.osgi.")) {
+ return osgiClassLoader.loadClass(name);
+ }
+ return super.loadClass(name, resolve);
+ }
+
+ };
+
+ ServiceLoader<FrameworkFactory> sLoader = ServiceLoader.load(FrameworkFactory.class, cl);
+ FrameworkFactory factory = sLoader.iterator().next();
+
+ File config = OSGiTestsActivator.getContext().getDataFile(getName()); //$NON-NLS-1$
+ Map<String, String> configuration = new HashMap<String, String>();
+ configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
+ configuration.put(EquinoxConfiguration.PROP_FRAMEWORK, relativeURL.toExternalForm());
+
+ Framework framework = factory.newFramework(configuration);
+ framework.init();
+ framework.stop();
+ framework.waitForStop(5000);
+
+ BundleRevision systemRevision1 = framework.adapt(BundleRevision.class);
+ int capCount1 = systemRevision1.getCapabilities(null).size();
+
+ framework = factory.newFramework(configuration);
+ framework.init();
+ framework.stop();
+ framework.waitForStop(5000);
+
+ BundleRevision systemRevision2 = framework.adapt(BundleRevision.class);
+ int capCount2 = systemRevision2.getCapabilities(null).size();
+
+ Assert.assertEquals("Wrong number of capabilities", capCount1, capCount2);
+ }
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
index d891eff5d..85c9ecd0a 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
@@ -1225,18 +1225,20 @@ public class Storage {
if (infoId == 0) {
content = getSystemContent();
isDirectory = content != null ? content.isDirectory() : false;
+ // Note that we do not do any checking for absolute paths with
+ // the system bundle. We always take the content as discovered
+ // by getSystemContent()
} else {
content = new File(contentPath);
- }
-
- if (content != null && !content.isAbsolute()) {
- // make sure it has the absolute location instead
- if (isReference) {
- // reference installs are relative to the installPath
- content = new File(installPath, contentPath);
- } else {
- // normal installs are relative to the storage area
- content = getFile(contentPath, true);
+ if (!content.isAbsolute()) {
+ // make sure it has the absolute location instead
+ if (isReference) {
+ // reference installs are relative to the installPath
+ content = new File(installPath, contentPath);
+ } else {
+ // normal installs are relative to the storage area
+ content = getFile(contentPath, true);
+ }
}
}

Back to the top