Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8225047

URLStreamHandler.openConnection(URL,Proxy) - spec and implementation mismatch

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 13
    • core-libs
    • None
    • behavioral
    • minimal
    • It is highly unlikely that any operational code could depend on the current implementation, since it simply throws `UnsupportedOperationException`.
    • Java API
    • SE

      Summary

      Specify the default implementation of java.net.URLStreamHandler.openConnection(URL,Proxy).

      Problem

      The current default implementation of openConnection(URL,Proxy) simply throws UnsupportedOperationException. Pedantically, this violates its own specification, since it does not throw IllegalArgumentException when passed a null value.

      Solution

      Update and specify the default implementation. Trivially, perform null argument checking, and subsequently throw UnsupportedOperationException ( since the URL stream handler implementation can realistically do nothing more ).

      Specification

        /*
         * 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.
         *
      +  * @implSpec
      +  * The default implementation of this method first checks that the given
      +  * {code URL} and {code Proxy} are not null, then throws {@code
      +  * UnsupportedOperationException}. Subclasses should override this method
      +  * with an appropriate implementation.
      +  *
         * @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
         */
        protected URLConnection openConnection(URL u, Proxy p) throws IOException

            chegar Chris Hegarty
            msomani Mohit Somani (Inactive)
            Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: