Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 9641 invoked from network); 30 Apr 2008 08:16:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Apr 2008 08:16:38 -0000 Received: (qmail 29639 invoked by uid 500); 30 Apr 2008 08:16:39 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 29618 invoked by uid 500); 30 Apr 2008 08:16:39 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 29607 invoked by uid 99); 30 Apr 2008 08:16:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Apr 2008 01:16:39 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Apr 2008 08:16:03 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 9C5D6234C109 for ; Wed, 30 Apr 2008 01:12:55 -0700 (PDT) Message-ID: <1371935819.1209543175639.JavaMail.jira@brutus> Date: Wed, 30 Apr 2008 01:12:55 -0700 (PDT) From: "Jimmy, Jing Lv (JIRA)" To: commits@harmony.apache.org Subject: [jira] Commented: (HARMONY-5788) [classlib][util] TreeMap.entrySet().contains() returns true for entries with null value In-Reply-To: <1536553912.1209046642232.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HARMONY-5788?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12593254#action_12593254 ] Jimmy, Jing Lv commented on HARMONY-5788: ----------------------------------------- Oops, sorry Mark I've made a mistake in the last post. It was trying to get a value, not an entry, so my fix is invalid. I believe your fix is correct! And IMHO, maybe we can refactor it a little as(as most entries will not have null value, this may improve performance as it avoid invoking containsKey(key) in most cases, which is costy): public boolean contains(Object object) { if (object instanceof Map.Entry) { Map.Entry entry = (Map.Entry) object; K key = entry.getKey(); Object v1 = TreeMap.this.get(key), v2 = entry.getValue(); return v1 == null ? TreeMap.this.containsKey(key) : v1.equals(v2); } return false; } > [classlib][util] TreeMap.entrySet().contains() returns true for entries with null value > --------------------------------------------------------------------------------------- > > Key: HARMONY-5788 > URL: https://issues.apache.org/jira/browse/HARMONY-5788 > Project: Harmony > Issue Type: Bug > Components: Classlib > Reporter: Mark Hindess > > The following code illustrates the problem: > import java.util.TreeMap; > public class TestTreeMap { > public static void main(String[] args) { > TreeMap master = new TreeMap(); > master.put("one", "1"); > master.put("null", null); > TreeMap map = new TreeMap(); > Object[] element = master.entrySet().toArray(); > for (int i = 0; i < element.length ; i++) { > System.out.println("Contains entry " + element[i] + "? == " + > map.entrySet().contains(element[i])); > } > } > } > On harmony, the output is: > Contains entry null=null? == true > Contains entry one=1? == false > on the RI, the output is: > Contains entry null=null? == false > Contains entry one=1? == false -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.