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: [EMAIL PROTECTED]


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to