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
GEODE-2999, GEODE-4836: Add PutIfAbsent to the Protobuf protocol. #1617
Conversation
try { | ||
region = messageExecutionContext.getCache().getRegion(regionName); | ||
} catch (IllegalArgumentException ex) { | ||
return Failure.of(BasicTypes.ErrorCode.INVALID_REQUEST, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a lot of handlers that depend on an extant region and thus have identical code for failing in its absence. Is this an opportunity to refactor this into a common, abstract base class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That might work. Let's put it in a separate PR.
Object decodedValue = serializationService.decode(entry.getValue()); | ||
Object decodedKey = serializationService.decode(entry.getKey()); | ||
|
||
if (decodedKey == null || decodedValue == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A null value is allowed & will create an entry with value INVALID. This is the same as create(K,null). I see that this isn't spelled out in the Region.putIfAbsent javadoc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is mentioned in the Javadoc. However, what an invalid entry isn't exactly spelled out. I'll take out the null check, as someone might use this functionality.
|
||
assertTrue(PdxInstance.class.isAssignableFrom(entry.getKey().getClass())); | ||
assertTrue(PdxInstance.class.isAssignableFrom(entry.getValue().getClass())); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a test for putIfAbsent(k,null) and assert that the region holds an entry that is INVALID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need that integration test. That's a matter of what PutIfAbsent
does; the tests for the operation handler just need to make sure that it's hooked up properly. I'll add a unit test for nulls.
fix issues with getRequest not properly returning null.
This reverts commit 7a3da49, which
originally reverted 6214a43.
This is a (hopefully) fixed version of #1578 .
Thank you for submitting a contribution to Apache Geode.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?
Has your PR been rebased against the latest commit within the target branch (typically
develop
)?Is your initial contribution a single, squashed commit?
Does
gradlew build
run cleanly?Have you written or updated unit tests to verify your changes?
If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and
submit an update to your PR as soon as possible. If you need help, please send an
email to dev@geode.apache.org.