JDK-5086348 : URL.openConnection(Proxy.NO_PROXY) throws NULLPointerException
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2004-08-12
  • Updated: 2012-10-09
  • Resolved: 2004-09-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6
5.0u1 01Fixed 6Fixed
Description
URL.openConnection(Proxy.NO_PROXY) throws NULLPointerException.

The implementation of URL.openConnection(Proxy p) does not check whether the InetSocketAddress returned by p.address() could be null if user passes Proxy.NO_PROXY. This will result NULLPointerException when people tries to use the API.
###@###.### 2004-08-12

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.5.0_01 mustang FIXED IN: 1.5.0_01 mustang INTEGRATED IN: 1.5.0_01 mustang
22-09-2004

SUGGESTED FIX public URLConnection openConnection(Proxy proxy) throws java.io.IOException { if (proxy == null) { throw new IllegalArgumentException("proxy can not be null"); } SecurityManager sm = System.getSecurityManager(); InetSocketAddress epoint = (InetSocketAddress) proxy.address(); ! if (epoint != null && sm != null) { if (epoint.isUnresolved()) sm.checkConnect(epoint.getHostName(), epoint.getPort()); else sm.checkConnect(epoint.getAddress().getHostAddress(), epoint.getPort()); } return handler.openConnection(this, proxy); }
22-09-2004

EVALUATION Right, a security check is made on the address of the proxy without checking for the special case of NO_PROXY where the address is null. Very easy to fix. Will do as soon as possible. ###@###.### 2004-08-12
12-08-2004

PUBLIC COMMENTS Add the null check to the method implementation will resolve the issue. A trivial fix, but important. ###@###.### 2004-08-12
12-08-2004