You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Marcel Offermans (JIRA)" <ji...@apache.org> on 2011/03/17 00:26:30 UTC

[jira] Created: (FELIX-2882) It's dangerous to use service instances as keys in a Map (in the http whiteboard bundle).

It's dangerous to use service instances as keys in a Map (in the http whiteboard bundle).
-----------------------------------------------------------------------------------------

                 Key: FELIX-2882
                 URL: https://issues.apache.org/jira/browse/FELIX-2882
             Project: Felix
          Issue Type: Bug
          Components: HTTP Service
    Affects Versions: http-2.2.0
            Reporter: Marcel Offermans
            Priority: Minor


In ExtenderManagerImpl.addMapping() the key that is used to store a tuple in a Map is actually the service instance that you get from the ServiceTracker. This is dangerous because you have absolutely no idea if that instance correctly implements equals() and hashCode(). It's usually better to use the ServiceReference as the key (which is guaranteed to correctly implement those methods). It's probably only a minor issue in practice, but still one you can look for a long time if it does bite you.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (FELIX-2882) It's dangerous to use service instances as keys in a Map (in the http whiteboard bundle).

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

Felix Meschberger resolved FELIX-2882.
--------------------------------------

    Resolution: Fixed

Replace the service instances by the service reference as the key of the mappings in Rev. 1210612
                
> It's dangerous to use service instances as keys in a Map (in the http whiteboard bundle).
> -----------------------------------------------------------------------------------------
>
>                 Key: FELIX-2882
>                 URL: https://issues.apache.org/jira/browse/FELIX-2882
>             Project: Felix
>          Issue Type: Bug
>          Components: HTTP Service
>    Affects Versions: http-2.2.0
>            Reporter: Marcel Offermans
>            Assignee: Felix Meschberger
>            Priority: Minor
>             Fix For: http-whiteboard-2.3.0
>
>
> In ExtenderManagerImpl.addMapping() the key that is used to store a tuple in a Map is actually the service instance that you get from the ServiceTracker. This is dangerous because you have absolutely no idea if that instance correctly implements equals() and hashCode(). It's usually better to use the ServiceReference as the key (which is guaranteed to correctly implement those methods). It's probably only a minor issue in practice, but still one you can look for a long time if it does bite you.

--
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] Commented: (FELIX-2882) It's dangerous to use service instances as keys in a Map (in the http whiteboard bundle).

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

Felix Meschberger commented on FELIX-2882:
------------------------------------------

Alternatively (and more easily probably) an IdentityHashMap could be used instead of a regular HashMap

> It's dangerous to use service instances as keys in a Map (in the http whiteboard bundle).
> -----------------------------------------------------------------------------------------
>
>                 Key: FELIX-2882
>                 URL: https://issues.apache.org/jira/browse/FELIX-2882
>             Project: Felix
>          Issue Type: Bug
>          Components: HTTP Service
>    Affects Versions: http-2.2.0
>            Reporter: Marcel Offermans
>            Priority: Minor
>
> In ExtenderManagerImpl.addMapping() the key that is used to store a tuple in a Map is actually the service instance that you get from the ServiceTracker. This is dangerous because you have absolutely no idea if that instance correctly implements equals() and hashCode(). It's usually better to use the ServiceReference as the key (which is guaranteed to correctly implement those methods). It's probably only a minor issue in practice, but still one you can look for a long time if it does bite you.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (FELIX-2882) It's dangerous to use service instances as keys in a Map (in the http whiteboard bundle).

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

Felix Meschberger commented on FELIX-2882:
------------------------------------------

To implement FELIX-3226 I have changed this to use the ServiceReference as the key
                
> It's dangerous to use service instances as keys in a Map (in the http whiteboard bundle).
> -----------------------------------------------------------------------------------------
>
>                 Key: FELIX-2882
>                 URL: https://issues.apache.org/jira/browse/FELIX-2882
>             Project: Felix
>          Issue Type: Bug
>          Components: HTTP Service
>    Affects Versions: http-2.2.0
>            Reporter: Marcel Offermans
>            Assignee: Felix Meschberger
>            Priority: Minor
>             Fix For: http-whiteboard-2.3.0
>
>
> In ExtenderManagerImpl.addMapping() the key that is used to store a tuple in a Map is actually the service instance that you get from the ServiceTracker. This is dangerous because you have absolutely no idea if that instance correctly implements equals() and hashCode(). It's usually better to use the ServiceReference as the key (which is guaranteed to correctly implement those methods). It's probably only a minor issue in practice, but still one you can look for a long time if it does bite you.

--
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] [Updated] (FELIX-2882) It's dangerous to use service instances as keys in a Map (in the http whiteboard bundle).

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

Felix Meschberger updated FELIX-2882:
-------------------------------------

    Fix Version/s: http-whiteboard-2.3.0
         Assignee: Felix Meschberger
    
> It's dangerous to use service instances as keys in a Map (in the http whiteboard bundle).
> -----------------------------------------------------------------------------------------
>
>                 Key: FELIX-2882
>                 URL: https://issues.apache.org/jira/browse/FELIX-2882
>             Project: Felix
>          Issue Type: Bug
>          Components: HTTP Service
>    Affects Versions: http-2.2.0
>            Reporter: Marcel Offermans
>            Assignee: Felix Meschberger
>            Priority: Minor
>             Fix For: http-whiteboard-2.3.0
>
>
> In ExtenderManagerImpl.addMapping() the key that is used to store a tuple in a Map is actually the service instance that you get from the ServiceTracker. This is dangerous because you have absolutely no idea if that instance correctly implements equals() and hashCode(). It's usually better to use the ServiceReference as the key (which is guaranteed to correctly implement those methods). It's probably only a minor issue in practice, but still one you can look for a long time if it does bite you.

--
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