[
https://issues.apache.org/jira/browse/SLING-2123?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13059354#comment-13059354
]
Antonio Sanso commented on SLING-2123:
--------------------------------------
+1
another alternative to the URL.toString is to use java.net.URI.
See also
http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html
> ContentLoader should not use an URL as a key in Map
> ---------------------------------------------------
>
> Key: SLING-2123
> URL: https://issues.apache.org/jira/browse/SLING-2123
> Project: Sling
> Issue Type: Bug
> Components: JCR
> Affects Versions: JCR ContentLoader 2.1.2
> Reporter: Felix Meschberger
>
> The JCR Content Loader's Loader class uses a HashMap<URL, String> to cache
> imported content. Using an URL as a key in a Map is problematic due to the
> URL class' implementation of the hashCode method.
> A customer of ours reported the following thread dump illustrating the issue:
> java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
> java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:867)
> java.net.InetAddress.getAddressFromNameService(InetAddress.java:1246)
> java.net.InetAddress.getAllByName0(InetAddress.java:1197)
> java.net.InetAddress.getAllByName(InetAddress.java:1128)
> java.net.InetAddress.getAllByName(InetAddress.java:1064)
> java.net.InetAddress.getByName(InetAddress.java:1014)
> java.net.URLStreamHandler.getHostAddress(URLStreamHandler.java:437)
> java.net.URLStreamHandler.hashCode(URLStreamHandler.java:354)
> java.net.URL.hashCode(URL.java:875)
> java.util.HashMap.getEntry(HashMap.java:361)
> java.util.HashMap.containsKey(HashMap.java:352)
>
> org.apache.sling.jcr.contentloader.internal.Loader.installFromPath(Loader.java:398)
> We should probably use URL.toString as the map key.
> See also http://www.eishay.com/2008/04/javas-url-little-secret.html
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira