OxalisCommunity / oxalis

Oxalis - PEPPOL Access Point open source implementation - Core component
Other
129 stars 91 forks source link

equals and hashCode method of URL perform domain name resolution #137

Closed telefunken closed 6 years ago

telefunken commented 10 years ago

Referring to eu.peppol.outbound.soap.SoapDispatcher: Maps and sets of URLs can be performance hogs.

This can result in a big performance hit and is marked by Sonar (FindBugs) as a blocking issue. I haven’t verified this is an issue in this particular case, but it is worth measuring. The common suggestion is: consider using java.net.URI instead.

How to reproduce (using SonarQube. IT is also reproduceable with plain FindBugs):

>git clone <repo>
>mvn install -Dmaven.test.skip=true
>mvn sonar:sonar -Dmaven.test.skip=true

See sonar output

This occurs in all JDKs (also 8): http://docs.oracle.com/javase/8/docs/api/java/net/URL.html#equals(java.lang.Object)

See also: http://michaelscharf.blogspot.fi/2006/11/javaneturlequals-and-hashcode-make.html

Findbugs issue “DMI_COLLECTION_OF_URLS”: http://findbugs.sourceforge.net/bugDescriptions.html

teedjay commented 10 years ago

I see the temporary blacklist function uses a map of URL's. During normal use the blacklist should be short (or empty) and the URL endpoints involved belonging to a small set og access points - so hopefully the underlying name resolution cache will prevent a huge performance penalty.

But I agree, we should write a test and do some measuring and perhaps rewrite the function. The URL's are fetched from the SMP and should be pretty much "static", so even a simple Map<String, Long> might be sufficient.