Permalink
Browse files

change behavior of replace and remove to call equals on the oldValue …

…like the other concurrent map impls
  • Loading branch information...
1 parent b1fcb8a commit 5ead76ce05d6fae9a1ed81099663cb3d037f64dc @moonpolysoft moonpolysoft committed Apr 27, 2011
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/org/cliffc/high_scale_lib/NonBlockingHashMap.java
@@ -331,7 +331,7 @@ private final void initialize( int initial_sz ) {
* @throws NullPointerException if the specified key or value is null */
public boolean remove ( Object key,Object val ) {
final Object out = putIfMatch(key, TOMBSTONE, val);
- return (out == null) ? out == val : out.equals(val);
+ return (val == null) ? out == val : val.equals(out);
}
/** Atomically do a <code>put(key,val)</code> if-and-only-if the key is
@@ -344,7 +344,7 @@ public boolean remove ( Object key,Object val ) {
* @throws NullPointerException if the specified key or value is null */
public boolean replace ( TypeK key, TypeV oldValue, TypeV newValue ) {
final Object out = putIfMatch(key, newValue, oldValue);
- return (out == null) ? out == oldValue : out.equals(oldValue);
+ return (val == null) ? out == oldValue : oldValue.equals(out);
}
private final TypeV putIfMatch( Object key, Object newVal, Object oldVal ) {

0 comments on commit 5ead76c

Please sign in to comment.