Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-6656

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

Add voteWatch issue
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 5.0M15
    • None
    • Classlib
    • None
    • All
    • 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).

      Attachments

        1. HARMONY-6656.diff
          4 kB
          Charles Lee

        Activity

          People

            Unassigned Unassigned
            littlee Charles Lee

            Dates

              Created:
              Updated:

              Slack

                Issue deployment