New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Nov 17, 2017

Conversation

Projects
None yet
2 participants
@henri-tremblay
Contributor

henri-tremblay commented Nov 16, 2017

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

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@nitsanw

This comment has been minimized.

Show comment
Hide comment
@nitsanw

nitsanw Nov 17, 2017

Contributor

Thanks!

Contributor

nitsanw commented Nov 17, 2017

Thanks!

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