[FLINK-5576] extend deserialization functions of KvStateRequestSerializer to detect unconsumed bytes #3174
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
KvStateRequestSerializer#deserializeValue()deserializes a given byte array. This is used by clients and unit tests and it is fair to assume that these byte arrays represent a complete value since we do not offer a method to continue reading from the middle of the array anyway. Therefore, we can treat unconsumed bytes as errors, e.g. from a wrong serializer being used, and throw anIOExceptionwith an appropriate failure message.Similarly, this adds a better failure message to exceptions in
KvStateRequestSerializer#deserializeList()by wrapping the originalIOExceptioninto a new one with an appropriate error message just as in #3172.The new unit tests require #3171 to be accepted first on which this PR is also based.