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

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

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Approved
    • Fix Version/s: 13
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      It is highly unlikely that any operational code could depend on the current implementation, since it simply throws `UnsupportedOperationException`.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: