You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2005/11/20 10:18:09 UTC
DO NOT REPLY [Bug 37567] New: -
StaticBucketMap#containsKey(final Object key) can return illegal value.
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