You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Felix Meschberger (JIRA)" <ji...@apache.org> on 2011/07/04 09:58:21 UTC

[jira] [Created] (SLING-2123) ContentLoader should not use an URL as a key in Map

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

        

[jira] [Assigned] (SLING-2123) ContentLoader should not use an URL as a key in Map

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-2123?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger reassigned SLING-2123:
----------------------------------------

    Assignee: Felix Meschberger

> 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
>            Assignee: Felix Meschberger
>             Fix For: JCR ContentLoader 2.1.4
>
>
> 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

        

[jira] [Closed] (SLING-2123) ContentLoader should not use an URL as a key in Map

Posted by "Carsten Ziegeler (Closed) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-2123?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carsten Ziegeler closed SLING-2123.
-----------------------------------

    
> 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
>            Assignee: Felix Meschberger
>             Fix For: JCR ContentLoader 2.1.4
>
>
> 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.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Issue Comment Edited] (SLING-2123) ContentLoader should not use an URL as a key in Map

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2123?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13059878#comment-13059878 ] 

Felix Meschberger edited comment on SLING-2123 at 7/5/11 12:55 PM:
-------------------------------------------------------------------

@Antonio: Yes, would be an option; but not needed here. toString is just enough

Changed Map<URL,...> to Map<String,...> in Rev. 1143034

      was (Author: fmeschbe):
    @Antonio: Yes, would be an option; but needed here. toString is just enough

Changed Map<URL,...> to Map<String,...> in Rev. 1143034
  
> 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

        

[jira] [Resolved] (SLING-2123) ContentLoader should not use an URL as a key in Map

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-2123?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger resolved SLING-2123.
--------------------------------------

       Resolution: Fixed
    Fix Version/s: JCR ContentLoader 2.1.4

Fixed.

> 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
>            Assignee: Felix Meschberger
>             Fix For: JCR ContentLoader 2.1.4
>
>
> 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

        

[jira] [Commented] (SLING-2123) ContentLoader should not use an URL as a key in Map

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2123?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13059878#comment-13059878 ] 

Felix Meschberger commented on SLING-2123:
------------------------------------------

@Antonio: Yes, would be an option; but needed here. toString is just enough

Changed Map<URL,...> to Map<String,...> in Rev. 1143034

> 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

        

[jira] [Commented] (SLING-2123) ContentLoader should not use an URL as a key in Map

Posted by "Antonio Sanso (JIRA)" <ji...@apache.org>.
    [ 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