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

URL.hashcode() and URL.equals() are greedy with DN lookups

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Not an Issue
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      URL often are used as keys for hashtables. E.g. see 6754990.
      Same is applicable to deployment cache, etc.

      If nothing is really download from the network then DNS lookups are one of most expensive operations that may happen. Especially if DNS access is slow.

      Proposed solution is:
        1) for hashcode() use only file/protocol/port unless file portion is really short
           In later case use host inet address too
        2) for hostEquals() - first check string representations and if they match then do not perform DNS lookup

      This version of hashcode() will still obey hashcode()/equals() contract. It will increase hashcode coincidence in some cases (if file paths are the same). But there are only few patterns when this may happen
      (e.g. root page of the site) and we can workaround some of them using minimal requirement on length of file portion.

      See suggested fix for details.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                chegar Chris Hegarty
                Reporter:
                igor Igor Nekrestyanov (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: