Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 98330 invoked from network); 17 Feb 2003 18:14:03 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 17 Feb 2003 18:14:03 -0000 Received: (qmail 8850 invoked by uid 97); 17 Feb 2003 18:15:38 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 8843 invoked from network); 17 Feb 2003 18:15:37 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 17 Feb 2003 18:15:37 -0000 Received: (qmail 98080 invoked by uid 500); 17 Feb 2003 18:14:00 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 98069 invoked from network); 17 Feb 2003 18:14:00 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 17 Feb 2003 18:14:00 -0000 Received: (qmail 8840 invoked by uid 50); 17 Feb 2003 18:15:35 -0000 Date: 17 Feb 2003 18:15:35 -0000 Message-ID: <20030217181535.8839.qmail@nagoya.betaversion.org> From: bugzilla@apache.org To: commons-dev@jakarta.apache.org Cc: Subject: DO NOT REPLY [Bug 17139] New: - StaticBucketMap.remove(Object) incorrectly handles key comparison X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17139 StaticBucketMap.remove(Object) incorrectly handles key comparison Summary: StaticBucketMap.remove(Object) incorrectly handles key comparison Product: Commons Version: 2.1 Final Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: Collections AssignedTo: commons-dev@jakarta.apache.org ReportedBy: leo.sutic@inspireinfrastructure.com I've found a bug in the StaticBucketMap class, the remove(Object) method: /** * Implements {@link Map#remove(Object)}. */ public Object remove( Object key ) { int hash = getHash( key ); synchronized( m_locks[ hash ] ) { Node n = m_buckets[ hash ]; Node prev = null; while( n != null ) { HERE>>>>>>>>> if( n.key == null || ( n.key != null && n.key.equals( key ) ) ) <<<<<<<<<<<<<<<<<< { // Remove this node from the linked list of nodes. if( null == prev ) { // This node was the head, set the next node to be the new head. m_buckets[ hash ] = n.next; } else { // Set the next node of the previous node to be the node after this one. prev.next = n.next; } m_locks[hash].size--; return n.value; } prev = n; n = n.next; } } return null; } The test is: if( n.key == null || ( n.key != null && n.key.equals( key ) ) ) should be: if( n.key == key || ( n.key != null && n.key.equals( key ) ) ) which is how it works in get(Object), containsKey(Object) etc. and which is correct. We have a match if the keys match using == OR if they are equal according to equals(). --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org