Harmony
  1. Harmony
  2. HARMONY-6656

[classlib][luni]HttpURLConnection.connect should throw ConnectException instead of IllegalArgumentException when the port is set to -1.

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 5.0M15
    • Fix Version/s: None
    • Component/s: Classlib
    • Labels:
      None
    • Environment:
      All
    • Patch Info:
      Patch Available

      Description

      The root cause is we set port is -1. Below is the description:
      1. -1 is set to be the default port. For example, http will set port to 80, https will set port to 443. See org.apache.harmony.luni.internal.net.www.protocol.http.HttpConfiguration.
      2. The uri in the HttpConfiguration is from the url.toURI(). If the url's port is -1, url.toURI().getHost() will return null (as expected).
      3. The connection will new a InetSocketAddress, whose parameter will be host(null) and port(default port). This will cause a IllegalArgumentException.

      What's in the patch:
      1. use uri.toURL().getHost() to get the orignal host instead of null.
      2. add the test case
      3. remove the unused code in the HttpConfiguration(URI uri, Proxy proxy).

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Li Jing Qin
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development