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

        

Reply via email to