[ 
https://issues.apache.org/jira/browse/COLLECTIONS-872?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17903910#comment-17903910
 ] 

Christopher Molin edited comment on COLLECTIONS-872 at 12/8/24 2:21 PM:
------------------------------------------------------------------------

Hi [~ggregory] !

Just to clarify, this is referring to 
[https://github.com/apache/commons-collections/tree/master]

This is the commons-collections that is being used:

 
{code:java}
<dependency>
    <groupId>commons-collections</groupId>
    <artifactId>commons-collections</artifactId>
</dependency> {code}
I believe the example you provided, is this one;
{code:java}
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-collections4</artifactId>
</dependency> {code}
Is this Jira project for both of these libraries?

 

EDIT: Nevermind, the problem I encountered is using commons-collections4:4.4

 

The problem was encountered using 4 keys - of different types.


was (Author: JIRAUSER308040):
Hi [~ggregory] !

Just to clarify, this is referring to 
[https://github.com/apache/commons-collections/tree/master]

This is the commons-collections that is being used:

 
{code:java}
<dependency>
    <groupId>commons-collections</groupId>
    <artifactId>commons-collections</artifactId>
</dependency> {code}
I believe the example you provided, is this one;
{code:java}
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-collections4</artifactId>
</dependency> {code}
Is this Jira project for both of these libraries?

 

> MultiKeyMap: Key-objects are stored as reference, making it possible to 
> modify the Map externally
> -------------------------------------------------------------------------------------------------
>
>                 Key: COLLECTIONS-872
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-872
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Map
>    Affects Versions: 2.0, 2.1, 2.1.1, 3.0, 3.1, 3.2, 3.2.1, 3.2.2, 
> 4.0-alpha1, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5.0-M1, 4.5.0-M2
>            Reporter: Christopher Molin
>            Priority: Critical
>
> When using MultiKeyMap, the keys are stored as-is (as references).
> This leads to the following problem:
>  # Create a MultiKeyMap, with key(s) of a type (class/{-}record{-}) which has 
> some fields.
>  # Use multiKeyMap.put(T... keys, V value), to create an entry in the Map, to 
> map the keys to a value
>  # Use multiKeyMap.get(T... keys), to verify that the mapping exists and 
> returns the expected value.
>  # Modify/alter any of the objects used as a key. It is enough to change the 
> value of any member field of any of the objects.
>  # Use multiKeyMap.get(T... keys) again, however, now there is no mapping for 
> these keys!
>  # Use multiKeyMap.get(T... keys) with the new modified/altered objects, and 
> it will return the expected value
> This is potentially a major issue - especially for those unaware of this 
> behavior!
>  
> This is a problem since the introduction in v1.17
>  
> Potential Solution:
> Calculate the Hash of the keys, and use those as keys. This way, would not be 
> subject to external modification.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to