QueryResponse in package software.amazon.awssdk.services.dynamodb.model. A method in that class lastEvaluatedKey() returns null when it is the last page and no further data can be retrieved. The return type is Map<String, AttributeValue>; the documentation says it should be empty and doesn't mention it would be null.
/**
* <p>
* The primary key of the item where the operation stopped, inclusive of the previous result set. Use this value to
* start a new operation, excluding this value in the new request.
* </p>
* <p>
* If <code>LastEvaluatedKey</code> is empty, then the "last page" of results has been processed and there is no
* more data to be retrieved.
* </p>
* <p>
* If <code>LastEvaluatedKey</code> is not empty, it does not necessarily mean that there is more data in the result
* set. The only way to know when you have reached the end of the result set is when <code>LastEvaluatedKey</code>
* is empty.
* </p>
* <p>
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
* </p>
*
* @return The primary key of the item where the operation stopped, inclusive of the previous result set. Use this
* value to start a new operation, excluding this value in the new request.</p>
* <p>
* If <code>LastEvaluatedKey</code> is empty, then the "last page" of results has been processed and there
* is no more data to be retrieved.
* </p>
* <p>
* If <code>LastEvaluatedKey</code> is not empty, it does not necessarily mean that there is more data in
* the result set. The only way to know when you have reached the end of the result set is when
* <code>LastEvaluatedKey</code> is empty.
*/
public Map<String, AttributeValue> lastEvaluatedKey() {
return lastEvaluatedKey;
}
Expected Behavior
As a caller of that method, I should be able to call method isEmpty on the returned value to check the existence of the lastKey, but that'd result in NPE which should never happen.
Current Behavior
NullPointerException
Possible Solution
Either update the documentation to say it'd return null in case the lastKey doesn't exist or initialize the lastEvaluatedKey with empty Map and ensure it is never null
QueryResponse
in packagesoftware.amazon.awssdk.services.dynamodb.model
. A method in that classlastEvaluatedKey()
returns null when it is the last page and no further data can be retrieved. The return type isMap<String, AttributeValue>
; the documentation says it should be empty and doesn't mention it would benull
.Expected Behavior
As a caller of that method, I should be able to call method
isEmpty
on the returned value to check the existence of the lastKey, but that'd result inNPE
which should never happen.Current Behavior
NullPointerException
Possible Solution
Either update the documentation to say it'd return
null
in case the lastKey doesn't exist or initialize thelastEvaluatedKey
with empty Map and ensure it is nevernull
Steps to Reproduce (for bugs)
Context
Your Environment
2.0.0-preview-6
jdk1.8.0_112