Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2016-10-25 20:22:25 +0000
committerThomas Watson2016-10-25 20:22:25 +0000
commit1b159b710232869ff92e6c4d013b8908deb4124f (patch)
treedc888261a56c399ce6668e876e510d18f08884e0
parent3250be05b0a2a81d903989181113ec1a0b3fd84b (diff)
downloadrt.equinox.framework-R3_9_maintenance.tar.gz
rt.equinox.framework-R3_9_maintenance.tar.xz
rt.equinox.framework-R3_9_maintenance.zip
Bug 506460 - openConnection(URL u, Proxy p) is unsupported when multipleR3_9_maintenance
frameworks are running Change-Id: I44b31638002212d08a0a47bd4d9511d88420cc3b Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--bundles/org.eclipse.osgi.tests/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/geturl/geturl/Activator.java13
-rw-r--r--bundles/org.eclipse.osgi.tests/pom.xml2
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java5
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/protocol/MultiplexingURLStreamHandler.java24
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/protocol/URLStreamHandlerFactoryProxyFor15.java1
6 files changed, 40 insertions, 7 deletions
diff --git a/bundles/org.eclipse.osgi.tests/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/META-INF/MANIFEST.MF
index 6bc5a1b33..848bb9cce 100644
--- a/bundles/org.eclipse.osgi.tests/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.osgi.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Core OSGi Tests
Bundle-SymbolicName: org.eclipse.osgi.tests;singleton:=true
-Bundle-Version: 3.9.0.qualifier
+Bundle-Version: 3.9.1.qualifier
Bundle-ClassPath: osgitests.jar
Bundle-Vendor: Eclipse.org
Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/geturl/geturl/Activator.java b/bundles/org.eclipse.osgi.tests/bundles_src/geturl/geturl/Activator.java
index 665c8e65e..1a17503c7 100644
--- a/bundles/org.eclipse.osgi.tests/bundles_src/geturl/geturl/Activator.java
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/geturl/geturl/Activator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2012 IBM Corporation and others.
+ * Copyright (c) 2010, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,8 +10,8 @@
*******************************************************************************/
package geturl;
-import java.net.MalformedURLException;
-import java.net.URL;
+import java.io.IOException;
+import java.net.*;
import java.security.PrivilegedAction;
import java.util.Dictionary;
import java.util.Hashtable;
@@ -40,8 +40,13 @@ public class Activator implements BundleActivator {
throw new RuntimeException("Could not create URL from parts: " + url);
}
url.toExternalForm();
- return Boolean.TRUE;
+ try {
+ url.openConnection(Proxy.NO_PROXY);
+ } catch (IOException e) {
+ // expected since our impl throws this
+ }
+ return Boolean.TRUE;
}
}, props);
}
diff --git a/bundles/org.eclipse.osgi.tests/pom.xml b/bundles/org.eclipse.osgi.tests/pom.xml
index 1fb93b712..915d5df03 100644
--- a/bundles/org.eclipse.osgi.tests/pom.xml
+++ b/bundles/org.eclipse.osgi.tests/pom.xml
@@ -19,7 +19,7 @@
</parent>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi.tests</artifactId>
- <version>3.9.0-SNAPSHOT</version>
+ <version>3.9.1-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<build>
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 97a297dea..df08e8ab8 100644
--- 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
@@ -1150,6 +1150,11 @@ public class SystemBundleTests extends AbstractBundleTests {
throw new IOException();
}
+ @Override
+ public URLConnection openConnection(URL u, Proxy p) throws IOException {
+ throw new IOException();
+ }
+
}
public void testURLMultiplexing01() throws BundleException {
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/protocol/MultiplexingURLStreamHandler.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/protocol/MultiplexingURLStreamHandler.java
index e3bb90f89..e2ba3429f 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/protocol/MultiplexingURLStreamHandler.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/protocol/MultiplexingURLStreamHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 Cognos Incorporated, IBM Corporation and others.
+ * Copyright (c) 2006, 2016 Cognos Incorporated, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,11 +11,13 @@ package org.eclipse.osgi.framework.internal.protocol;
import java.io.IOException;
import java.lang.reflect.*;
import java.net.*;
+import java.net.Proxy;
import org.eclipse.osgi.framework.internal.core.Framework;
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
public class MultiplexingURLStreamHandler extends URLStreamHandler {
private static Method openConnectionMethod;
+ private static Method openConnectionProxyMethod;
private static Method equalsMethod;
private static Method getDefaultPortMethod;
private static Method getHostAddressMethod;
@@ -39,6 +41,9 @@ public class MultiplexingURLStreamHandler extends URLStreamHandler {
openConnectionMethod = URLStreamHandler.class.getDeclaredMethod("openConnection", new Class[] {URL.class}); //$NON-NLS-1$
openConnectionMethod.setAccessible(true);
+ openConnectionProxyMethod = URLStreamHandler.class.getDeclaredMethod("openConnection", new Class[] {URL.class, Proxy.class}); //$NON-NLS-1$
+ openConnectionProxyMethod.setAccessible(true);
+
equalsMethod = URLStreamHandler.class.getDeclaredMethod("equals", new Class[] {URL.class, URL.class}); //$NON-NLS-1$
equalsMethod.setAccessible(true);
@@ -105,6 +110,23 @@ public class MultiplexingURLStreamHandler extends URLStreamHandler {
throw new MalformedURLException();
}
+ protected URLConnection openConnection(URL url, Proxy proxy) throws IOException {
+ URLStreamHandler handler = findAuthorizedURLStreamHandler(protocol);
+ if (handler != null) {
+ try {
+ return (URLConnection) openConnectionProxyMethod.invoke(handler, new Object[] {url, proxy});
+ } catch (InvocationTargetException e) {
+ if (e.getTargetException() instanceof IOException)
+ throw (IOException) e.getTargetException();
+ throw (RuntimeException) e.getTargetException();
+ } catch (Exception e) {
+ factory.adaptor.getFrameworkLog().log(new FrameworkLogEntry(MultiplexingURLStreamHandler.class.getName(), FrameworkLogEntry.ERROR, 0, "openConnection", 0, e, null)); //$NON-NLS-1$
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+ throw new MalformedURLException();
+ }
+
protected boolean equals(URL url1, URL url2) {
URLStreamHandler handler = findAuthorizedURLStreamHandler(protocol);
if (handler != null) {
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/protocol/URLStreamHandlerFactoryProxyFor15.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/protocol/URLStreamHandlerFactoryProxyFor15.java
index ddfaf80f3..c2044ca8b 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/protocol/URLStreamHandlerFactoryProxyFor15.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/protocol/URLStreamHandlerFactoryProxyFor15.java
@@ -28,6 +28,7 @@ public class URLStreamHandlerFactoryProxyFor15 extends URLStreamHandlerProxy {
protected URLConnection openConnection(URL u, Proxy p) throws IOException {
try {
Method openConn = realHandlerService.getClass().getMethod("openConnection", new Class[] {URL.class, Proxy.class}); //$NON-NLS-1$
+ openConn.setAccessible(true);
return (URLConnection) openConn.invoke(realHandlerService, new Object[] {u, p});
} catch (InvocationTargetException e) {
if (e.getTargetException() instanceof IOException)

Back to the top