diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CollectionContainsUrl.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CollectionContainsUrl.html index 902cafdf7e4a..4f22dc3e331a 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/CollectionContainsUrl.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CollectionContainsUrl.html @@ -1,15 +1,13 @@ -Reports instantiations of java.util.Set and java.util.Map that contain +Reports java.util.Set and java.util.Map variables that contain java.net.URL objects. +Such collections will call the equals() and hashCode() methods on inserted objects, +which can cause performance problems on URL objects.

- Adding URL objects to such collections can cause performance problems because of calls to - the equals() and hashCode() methods of URL. -

-

- URL's equals() and - hashCode() methods use a DNS lookup, which depending on the availability of the network and the speed of the DNS server can - cause significant delays. + URL's equals() and hashCode() methods can perform a DNS lookup to resolve the host name. + This may cause significant delays, depending on the availability and speed of the network and the DNS server. + Using java.net.URI instead of java.net.URL will avoid the DNS lookup.

Example:


diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsHashCodeCalledOnUrl.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsHashCodeCalledOnUrl.html
index ba35fcda6f38..a6a797fc8fb9 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsHashCodeCalledOnUrl.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsHashCodeCalledOnUrl.html
@@ -1,18 +1,15 @@
 
 
-Reports hashCode() and equals() being called on java.net.URL objects.
+Reports hashCode() and equals() calls on java.net.URL objects.
 

- The java.net.URL class internally uses an instance of java.net.URLStreamHandler - to execute hashCode() and equals(). - This can cause performance problems because java.net.URLStreamHandler performs DNS lookups. - Depending on the availability of the network and the speed of a DNS server this can cause significant delays. + URL's equals() and hashCode() methods can perform a DNS lookup to resolve the host name. + This may cause significant delays, depending on the availability and speed of the network and the DNS server. + Using java.net.URI instead of java.net.URL will avoid the DNS lookup.

-

The problem can most likely be solved by using java.net.URI instead.

Example:


-  int f(URL url1, URL url2) {
-    if (url1.equals(url2)) return url1.hashCode();
-    else return url2.hashCode();
+  int equalsHashCode(URL url1, URL url2) {
+    return url1.hashCode() == url2.hashCode();
   }