wtf nth

  • Archive
  • RSS

I Wish Java Had Good Generics

Do you see the problem with this code?

// map from url as a string to content for that url
// apparently URL.equals() is bad:
// http://javaantipatterns.wordpress.com/2007/11/24/comparing-urls-with-urlequals/
private static Map<String, String> urlCache = Maps.newHashMap();

private static String getURLContent(URL url) throws IOException {
  if (urlCache.containsKey(url.toString())) {
    return urlCache.get(url);
  }
  // ...
}

I wish it wouldn’t even compile.

(Problem: using url instead of url.toString() in get())

  • 5 months ago
  • Permalink
  • Share
    Tweet
← Previous • Next →

About

stuff I learned the hard way

Pages

  • why
  • me
  • RSS
  • Random
  • Archive
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr