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
IGNITE-21836: KeyValueView. GetNullable produces confusing error for a PoJo when field / column nullability do not match #3714
Conversation
ce785f5
to
9d03cb4
Compare
…a PoJo when field / column nullability do not match
@@ -229,6 +235,11 @@ public CompletableFuture<Void> putAllAsync(@Nullable Transaction tx, Map<K, V> p | |||
return nullCompletedFuture(); | |||
} | |||
|
|||
for (Entry<K, V> e : pairs.entrySet()) { | |||
Objects.requireNonNull(e.getKey()); |
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.
should we add some message to help a user identify a problem?
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.
We should. But all assertions in this classes and their siblings do not return any message.
*/ | ||
public static void validateNullableOperation(Class<?> valueType) { | ||
if (!Mapper.nativelySupported(valueType)) { | ||
String message = format("`getNullable`* methods cannot be used when a value is not mapped to a simple type"); |
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.
the method is utility and isn't linked to concrete classes that will be used. Maybe better to pass a method name as a parameter to form the message
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.
This code uses already established pattern see ClientKeyValueView::throwIfNull
its callers.
throw new UnexpectedNullValueException("Got unexpected null value: use
getNullable
sibling method instead.");
Table table = ignite().tables().table("T1"); | ||
KeyValueView<Integer, Boolean> view = table.keyValueView(Mapper.of(Integer.class), Mapper.of(Boolean.class)); | ||
|
||
assertEquals(NullableValue.of(null), view.getNullable(null, 1)); |
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.
maybe we can make NullableValue.NULL is public
} | ||
|
||
private static void expectNullNotAllowed(Executable exec) { | ||
NullPointerException err = assertThrows(NullPointerException.class, exec); |
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.
we have IgniteTestUtils.assert*
methods
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.
fixed
K key = entry.getKey(); | ||
V val = entry.getValue(); | ||
|
||
Objects.requireNonNull(key); |
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 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.
Added variable names to requireNonNull
calls.
…a PoJo when field / column nullability do not match
…a PoJo when field / column nullability do not match
…a PoJo when field / column nullability do not match
…a PoJo when field / column nullability do not match
…a PoJo when field / column nullability do not match
…a PoJo when field / column nullability do not match
/** | ||
* Embedded client nulls in operations test. | ||
*/ | ||
public class ItThinClientNullsEmbeddedTest extends ItThinClientNullsTest { |
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.
client is either thin or embedded
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.
Thanks. Fixed.
…a PoJo when field / column nullability do not match rename.
…a PoJo when field / column nullability do not match fix tests.
Objects.requireNonNull(key); | ||
Objects.requireNonNull(key, "key"); | ||
|
||
return doGet(tx, key, "getNullableAsync"); |
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.
should it be a
return doGet(tx, key, "getNullableAsync"); | |
return doGet(tx, key, "getAsync"); |
?
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 few such places
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.
No, it should not. It reports what method should be used instead.
https://issues.apache.org/jira/browse/IGNITE-21836
Thank you for submitting the pull request.
To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:
The Review Checklist
- There is a single JIRA ticket related to the pull request.
- The web-link to the pull request is attached to the JIRA ticket.
- The JIRA ticket has the Patch Available state.
- The description of the JIRA ticket explains WHAT was made, WHY and HOW.
- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
Notes