commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary D. Gregory (Commented) (JIRA)" <>
Subject [jira] [Commented] (COLLECTIONS-394) FastTreeMap is not compatible with TreeMap
Date Wed, 29 Feb 2012 14:51:57 GMT


Gary D. Gregory commented on COLLECTIONS-394:

Would you be willing to provide a patch for unit test and code?

Thank you.
> FastTreeMap is not compatible with TreeMap
> ------------------------------------------
>                 Key: COLLECTIONS-394
>                 URL:
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Map
>    Affects Versions: 3.2.1
>         Environment: all
>            Reporter: Michael Pradel
> FastTreeMap extends TreeMap in a way that doesn't preserve the superclass behavior. For
example, the following code prints 'null', but I would expect it to print '1=1', which is
what TreeMap does:
> TreeMap map = new FastTreeMap();
> //TreeMap map = new TreeMap();
> map.put(1, "1");
> map.put(3, "3");
> Entry e = map.floorEntry(2);
> System.out.println(e);
> This behavior is surprising and can hit you every time a reference of type TreeMap refers
to an instance of FastTreeMap. A subclass instance used through a superclass interface shouldn't
change the visible behavior of its superclass.
> The reason for this problem seems to be that FastTreeMap both extends TreeMap and delegates
to a TreeMap via the 'map' field. I.e., there are  two map instances for a single FastTreeMap

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message