Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4EEC6187CF for ; Fri, 27 Nov 2015 21:48:21 +0000 (UTC) Received: (qmail 97470 invoked by uid 500); 27 Nov 2015 21:48:13 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 97173 invoked by uid 500); 27 Nov 2015 21:48:13 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 96217 invoked by uid 99); 27 Nov 2015 21:48:12 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Nov 2015 21:48:12 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 70CC32C1F8E for ; Fri, 27 Nov 2015 21:48:12 +0000 (UTC) Date: Fri, 27 Nov 2015 21:48:12 +0000 (UTC) From: "Thomas Neidhart (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Closed] (COLLECTIONS-394) FastTreeMap is not compatible with TreeMap MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/COLLECTIONS-394?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thomas Neidhart closed COLLECTIONS-394. --------------------------------------- > FastTreeMap is not compatible with TreeMap > ------------------------------------------ > > Key: COLLECTIONS-394 > URL: https://issues.apache.org/jira/browse/COLLECTIONS-394 > 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 instance. -- This message was sent by Atlassian JIRA (v6.3.4#6332)