Skip to content

Commit

Permalink
Reverse equals arguments for overlock AtomicMap compatibility
Browse files Browse the repository at this point in the history
Overlock's atomic map wraps map values with OneShotThunk and strips them on
retrieval. Unfortunately JCTool's NonBlockingHashMap performs an `.equals` call
in various methods, and this fails when the object is not a OneShotThunk as
their equals methods (correctly) say they are not equal to a
OneShotThunk. Reversing the order means the overriden .equals method in
OneShotThunk returns true if the argument is the same value or a OneShotThunk
wrapping the same value.
  • Loading branch information
rnewson committed Nov 14, 2024
1 parent a17b56f commit fef3d47
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public boolean replace ( TypeK key, TypeV oldValue, TypeV newValue ) {
return objectsEquals(putIfMatch( key, newValue, oldValue ), oldValue);
}
private static boolean objectsEquals(Object a, Object b) {
return (a == b) || (a != null && a.equals(b));
return (a == b) || (b != null && b.equals(a));
}

// Atomically replace newVal for oldVal, returning the value that existed
Expand Down

0 comments on commit fef3d47

Please sign in to comment.