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

(spec) Confusing specification of the URLStreamHandler.openConnection method

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 7
    • core-libs
    • Cause Known
    • x86
    • linux

      -----------------------------
      protected abstract URLConnection openConnection(URL u)
                                               throws IOException

          Opens a connection to the object referenced by the URL argument. This method should be overridden by a subclass.
      ...............................
      ----------------------------------

      This phrase looks a bit confusing because this method is not intended to establish connection. It should just return URLConnection instance and it's connect method is used to establish connection.

      BTW, there is URL.openConnection method with similar functionality and in earlier JDK versions
      it had the similar confusing description. However now it is described more clearly:

      ------------------------------------------
      public URLConnection openConnection()
                                   throws IOException

          Returns a URLConnection instance that represents a connection to the remote object referred to by the URL.

          A new instance of URLConnection is created every time when invoking the URLStreamHandler.openConnection(URL) method of the protocol handler for this URL.

          It should be noted that a URLConnection instance does not establish the actual network connection on creation. This will happen only when calling URLConnection.connect().
      --------------------------------------------

      I think something similar should be specified for URLStreamHandler.openConnection

            chegar Chris Hegarty
            sreznick Sergey Reznick (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: