-
Bug
-
Resolution: Fixed
-
P3
-
6.0, 5.0, 7, 8, 9, 10, 11, 12, 13
-
b24
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8225880 | 14 | Chris Hegarty | P3 | Resolved | Fixed | team |
java.net.URLStreamHandler::openConnection(java.net.URL,java.net.Proxy)
implementation says :
throw new UnsupportedOperationException("Method not implemented.");
but spec says :
/**
* Same as openConnection(URL), except that the connection will be
* made through the specified proxy; Protocol handlers that do not
* support proxying will ignore the proxy parameter and make a
* normal connection.
*
* Calling this method preempts the system's default
* {@link java.net.ProxySelector ProxySelector} settings.
*
* @param u the URL that this connects to.
* @param p the proxy through which the connection will be made.
* If direct connection is desired, Proxy.NO_PROXY
* should be specified.
* @return a {@code URLConnection} object for the {@code URL}.
* @exception IOException if an I/O error occurs while opening the
* connection.
* @exception IllegalArgumentException if either u or p is null,
* or p has the wrong type.
* @exception UnsupportedOperationException if the subclass that
* implements the protocol doesn't support this method.
* @since 1.5
*/
So following is expected to thrown IllegalArgumentException but UnsupportedOperationException is the one that is always thrown
CustomURLStreamHandler customURLStreamHandler = new CustomURLStreamHandler();
customURLStreamHandler.openConnection(null, null);
// above should throw IllegalArgumentException
class CustomURLStreamHandler extends URLStreamHandler {
public CustomURLStreamHandler() {
}
public URLConnection openConnection(URL var1) {
return null;
}
public URLConnection openConnection(URL url, Proxy proxy) throws IOException {
return super.openConnection(url, proxy);
}
}
implementation says :
throw new UnsupportedOperationException("Method not implemented.");
but spec says :
/**
* Same as openConnection(URL), except that the connection will be
* made through the specified proxy; Protocol handlers that do not
* support proxying will ignore the proxy parameter and make a
* normal connection.
*
* Calling this method preempts the system's default
* {@link java.net.ProxySelector ProxySelector} settings.
*
* @param u the URL that this connects to.
* @param p the proxy through which the connection will be made.
* If direct connection is desired, Proxy.NO_PROXY
* should be specified.
* @return a {@code URLConnection} object for the {@code URL}.
* @exception IOException if an I/O error occurs while opening the
* connection.
* @exception IllegalArgumentException if either u or p is null,
* or p has the wrong type.
* @exception UnsupportedOperationException if the subclass that
* implements the protocol doesn't support this method.
* @since 1.5
*/
So following is expected to thrown IllegalArgumentException but UnsupportedOperationException is the one that is always thrown
CustomURLStreamHandler customURLStreamHandler = new CustomURLStreamHandler();
customURLStreamHandler.openConnection(null, null);
// above should throw IllegalArgumentException
class CustomURLStreamHandler extends URLStreamHandler {
public CustomURLStreamHandler() {
}
public URLConnection openConnection(URL var1) {
return null;
}
public URLConnection openConnection(URL url, Proxy proxy) throws IOException {
return super.openConnection(url, proxy);
}
}
- backported by
-
JDK-8225880 URLStreamHandler.openConnection(URL,Proxy) - spec and implementation mismatch
-
- Resolved
-
- csr for
-
JDK-8225047 URLStreamHandler.openConnection(URL,Proxy) - spec and implementation mismatch
-
- Closed
-