Fix cassandra protocol null handling #784
Merged
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.
Previously our implementation of the cassandra protocol was succesfully decoding null values but when it tried to reencode the null value it would output the bytes
00 00 00 04 FF FF FF FF
instead of justFF FF FF FF
.This resulted in e.g. null ip addresses showing up as 255.255.255.255 and integers as -1.
Unfortunately solving this requires completely rewriting
cassandra-protocol
s encoding implementation because of some poor fundamental decisions made there.The problem is that the recursive generation (for e.g. List and Map types) relies on the
Bytes
variousimpl From<T> for Bytes
.However its impossible to represent a Null value on a
Bytes
, instead theBytes
needs to be wrapped in a CBytes in order to represent NullThis makes it impossible to handle both recursive types (list/map/set etc) and Null values using cassandra-protocol.
In order to get this working immediately for us I've just implemented the changes directly in shotover, its only a little more code shotover side but the custom implementation is:
into()
implementations)