commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 37567] New: - StaticBucketMap#containsKey(final Object key) can return illegal value.
Date Sun, 20 Nov 2005 09:18:09 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37567>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=37567

           Summary: StaticBucketMap#containsKey(final Object key) can return
                    illegal value.
           Product: Commons
           Version: 3.1
          Platform: All
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Collections
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: ujihara@aurora.dti.ne.jp


org.apache.commons.collections.map.StaticBucketMap#containsKey("any string") 
can return true by mistake when null key is containing in buckets.
I think containsKey(Object) method has to be modified like the following.

    public boolean containsKey(final Object key) {
        int hash = getHash(key);

        synchronized (locks[hash]) {
            Node n = buckets[hash];

            while (n != null) {
-                if (n.key == null || (n.key != null && n.key.equals(key))) {
+                if ((n.key == null && key == null) || (n.key != null && 
n.key.equals(key))) {
                    return true;
                }

                n = n.next;
            }
        }
        return false;
    }

Kazuya Ujihara

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message