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

URI and URL conflicts with dealing with hostname contains underscore

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE REQUEST :
      Hi,

      I am reporting a bug or an enhancement referring to the bug id [8132508](http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8132508).

      Referring the comments:

      ```
      RFC 952 disallows _ underscores in hostnames. So, this is not a bug. I also haven't been able to find examples of actual usage.
      So, unless a particularly compelling case can be made, I'm closing as not a bug.
      ```

      However, if hostname contains underscores is not a valid hostname, why it is in java.net.URL? More clearly, valid in java.net.URL INvalid in java.net.URI. These issue often confused developers and cannot get the consistent on lot of third-part jars.

      The following statements demonstrate this issue:

      new java.net.URI("http://test_1.tanglei.name").getHost() // = null
      new java.net.URL("http://test_1.tanglei.name").getHost() // "test_1.tanglei.name"

      Wish your reply.


      JUSTIFICATION :
      The following statements demonstrate this issue:

      new java.net.URI("http://test_1.tanglei.name").getHost() // = null
      new java.net.URL("http://test_1.tanglei.name").getHost() // "test_1.tanglei.name"

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      If the underscore is not valid in hostname, both URL and URI getHost should return null.
      ACTUAL -
      new java.net.URI("http://test_1.tanglei.name").getHost() return null
      new java.net.URL("http://test_1.tanglei.name").getHost() return "test_1.tanglei.name"

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: