[ 
https://issues.apache.org/jira/browse/COLLECTIONS-579?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Thomas Neidhart resolved COLLECTIONS-579.
-----------------------------------------
    Resolution: Invalid

A plain array can not be used as-is in collection-like classes.

The reason for this is that an Array will use the default hashCode 
implementation from Object which means its hashcode depends on its reference. 
You can test the same example and replace the PassiveExpiringMap with a normal 
HashMap and you will get the same behavior just because the hashCode for key 
and queryKey will be different.

In order to use arrays in a Map you will need a wrapper that properly 
implements hashCode and equals by using e.g. the functions available in the 
Arrays class.

> PassiveExpiringMap doesn't work when the key is a byte array
> ------------------------------------------------------------
>
>                 Key: COLLECTIONS-579
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-579
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Map
>    Affects Versions: 4.0
>         Environment: GNU/Linux Ubuntu 15.10 64 bits, OpenJDK 1.8.0_65
>            Reporter: Roger R Andrews
>
> When you put a (key,value) pair in a PassiveExpiringMap and the key is byte[] 
> you can't retrieve it.
> Code to reproduce the problem:
> byte[] key = {0,0,0,1};
> PassiveExpiringMap<byte[],byte[]> map = new PassiveExpiringMap<byte[],byte[]> 
> ();
> map.put(key,key);
> byte[] queryKey = {0,0,0,1};
> //this should be true
> map.containsKey(queryKey) == false



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to