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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P2
    • None
    • 6
    • core-libs
    • generic
    • 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

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

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: