aboutsummaryrefslogtreecommitdiff
path: root/src/share/classes/java/net/URL.java
diff options
context:
space:
mode:
authorjccollet <none@none>2009-05-05 11:02:51 +0200
committerjccollet <none@none>2009-05-05 11:02:51 +0200
commitecf1a4e2b3326fe397df8dc8109e37152fa521cf (patch)
treebaabd1dc85f876e6af2c84ce07b86924c3bf01ad /src/share/classes/java/net/URL.java
parentee8d7b1ada3c3f80002deccc775354c67e237a3c (diff)
downloadjdk8u_jdk-ecf1a4e2b3326fe397df8dc8109e37152fa521cf.tar.gz
6801497: Proxy is assumed to be immutable but is non-final
Summary: Cloned the proxy instance when necessary Reviewed-by: chegar
Diffstat (limited to 'src/share/classes/java/net/URL.java')
-rw-r--r--src/share/classes/java/net/URL.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/share/classes/java/net/URL.java b/src/share/classes/java/net/URL.java
index bb934d9b74..73818e960d 100644
--- a/src/share/classes/java/net/URL.java
+++ b/src/share/classes/java/net/URL.java
@@ -1004,16 +1004,18 @@ public final class URL implements java.io.Serializable {
throw new IllegalArgumentException("proxy can not be null");
}
+ // Create a copy of Proxy as a security measure
+ Proxy p = proxy == Proxy.NO_PROXY ? Proxy.NO_PROXY : new Proxy(proxy.type(), proxy.address());
SecurityManager sm = System.getSecurityManager();
- if (proxy.type() != Proxy.Type.DIRECT && sm != null) {
- InetSocketAddress epoint = (InetSocketAddress) proxy.address();
+ if (p.type() != Proxy.Type.DIRECT && sm != null) {
+ InetSocketAddress epoint = (InetSocketAddress) p.address();
if (epoint.isUnresolved())
sm.checkConnect(epoint.getHostName(), epoint.getPort());
else
sm.checkConnect(epoint.getAddress().getHostAddress(),
epoint.getPort());
}
- return handler.openConnection(this, proxy);
+ return handler.openConnection(this, p);
}
/**