Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2016-10-25 16:29:10 +0000
committerThomas Watson2016-10-25 16:48:21 +0000
commit6f0aa116164ab33a68febb38ac60abd8e8e77b7d (patch)
tree3b96cfc8ff310197abfbc7d8e1bf3e46572aae21 /bundles/org.eclipse.osgi/container
parent8f1121b25d14ad9c88b63f21f43e9afdb95acfbc (diff)
downloadrt.equinox.framework-6f0aa116164ab33a68febb38ac60abd8e8e77b7d.tar.gz
rt.equinox.framework-6f0aa116164ab33a68febb38ac60abd8e8e77b7d.tar.xz
rt.equinox.framework-6f0aa116164ab33a68febb38ac60abd8e8e77b7d.zip
Bug 506460 - openConnection(URL u, Proxy p) is unsupported when multipleI20161025-2000
frameworks are running Change-Id: I44b31638002212d08a0a47bd4d9511d88420cc3b Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Diffstat (limited to 'bundles/org.eclipse.osgi/container')
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingURLStreamHandler.java25
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerProxy.java1
2 files changed, 25 insertions, 1 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingURLStreamHandler.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingURLStreamHandler.java
index 025e6a485..c82ab15ed 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingURLStreamHandler.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/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,10 +11,12 @@ package org.eclipse.osgi.internal.url;
import java.io.IOException;
import java.lang.reflect.*;
import java.net.*;
+import java.net.Proxy;
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;
@@ -38,6 +40,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);
@@ -104,6 +109,24 @@ public class MultiplexingURLStreamHandler extends URLStreamHandler {
throw new MalformedURLException();
}
+ @Override
+ 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.container.getLogServices().log(MultiplexingURLStreamHandler.class.getName(), FrameworkLogEntry.ERROR, "openConnection", e); //$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/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerProxy.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerProxy.java
index 85c904771..563da3d1e 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerProxy.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerProxy.java
@@ -224,6 +224,7 @@ public class URLStreamHandlerProxy extends URLStreamHandler implements ServiceTr
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