diff options
author | jccollet <none@none> | 2009-05-05 11:02:51 +0200 |
---|---|---|
committer | jccollet <none@none> | 2009-05-05 11:02:51 +0200 |
commit | ecf1a4e2b3326fe397df8dc8109e37152fa521cf (patch) | |
tree | baabd1dc85f876e6af2c84ce07b86924c3bf01ad /src/share/classes/java/net/URL.java | |
parent | ee8d7b1ada3c3f80002deccc775354c67e237a3c (diff) | |
download | jdk8u_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.java | 8 |
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); } /** |