JDK-4375334 : Takes 20 seconds to get hashCode() of a single URL
  • Type: Enhancement
  • Component: docs
  • Sub-Component: guides
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2000-09-30
  • Updated: 2001-10-29
  • Resolved: 2001-10-29
Related Reports
Duplicate :  
Description

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) 
======================================================================

Comments
WORK AROUND Name: rmT116609 Date: 09/29/2000 Use URL.toExternalForm() to get the String version of a URL, and use the String for hashing or comparison. ======================================================================
11-06-2004

EVALUATION I've started to investigate this, and will resolve the issue soon. scott.hommel@eng 2001-05-22 The docs have already been updated to say that the operations are blocking. Closing as dupicate of 4434494. ###@###.### 2001-10-29
22-05-2001