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

Takes 20 seconds to get hashCode() of a single URL

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.0
    • docs
    • x86
    • windows_2000



      Name: rmT116609 Date: 09/29/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      It can take up to 20-25 seconds to make the hash code of a single URL!
      This value seems to be cached for additional hashes of different URL objects
      with the same value. This is also true for the URL equals() method. The time
      varies a lot depending on the particular URL.

      I assume that this is because the URL actually tries to lookup the host on the
      network, and caches that result??? If so, this should be documented in the API!

      Simple test:

      URL url = new URL("http://www.guitarsphere.com");
      Date start = new Date();
      int hashCode = url.hashCode();
      Date end = new Date();
      System.out.println( "Time to make hash code: " +
      (end.getTime()-start.getTime()));
      (Review ID: 110066)
      ======================================================================

            shommel Scott Hommel (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: