Skip to content

ConcurrentMap contract requires to give a result based on equals, not on reference equality#202

Merged
nitsanw merged 1 commit into
JCTools:masterfrom
henri-tremblay:equals
Nov 17, 2017
Merged

ConcurrentMap contract requires to give a result based on equals, not on reference equality#202
nitsanw merged 1 commit into
JCTools:masterfrom
henri-tremblay:equals

Conversation

@henri-tremblay

@henri-tremblay henri-tremblay commented Nov 16, 2017

Copy link
Copy Markdown
Contributor

According to the Javadoc, true should be returned in case of equality for both remove and replace.

if (map.containsKey(key) && Objects.equals(map.get(key), oldValue)) {
  map.put(key, newValue);
  return true;
} else
  return false;

The replacement and removal are correctly done using equals, however the return value is currently based on reference equality. This patch solves this issue using Objects.equals.

@nitsanw nitsanw merged commit a2191c1 into JCTools:master Nov 17, 2017
@nitsanw

nitsanw commented Nov 17, 2017

Copy link
Copy Markdown
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants