Skip to content
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

Use checked casts when reading vints as ints #2043

Closed
wants to merge 2 commits into from

Conversation

aweisberg
Copy link
Contributor

patch by Ariel Weisberg; reviewed by ? and ? for CASSANDRA-18099

Copy link
Contributor

@dcapwell dcapwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 assuming we all agree on the name =). It sounds like readUnsignedVInt32, but I am cool with other names

@aweisberg
Copy link
Contributor Author

So I think one thing to be aware of is that we aren't reading an unsigned int32. There is maybe zero code that handles unsigned int32s? We are casting to a signed int and the checked cast is for a signed ints range of values.

@aweisberg aweisberg force-pushed the cassandra-18099-trunk branch 2 times, most recently from a423bc6 to 11ee42d Compare December 6, 2022 21:38
@belliottsmith
Copy link
Contributor

For consistency with the existing API though the valid thing to do would be to simply check its populating at most 32 bits, and if the 32nd bit is set it’s a negative int that may (or may not) be interpreted by the caller as an unsigned value.

That said, we could instead introduce eg readNaturalInt32 which would expect at most 31bits to be set, which might be better.

@aweisberg aweisberg force-pushed the cassandra-18099-trunk branch 5 times, most recently from db79471 to 6016e68 Compare December 8, 2022 21:55
@aweisberg
Copy link
Contributor Author

OK, this looks like it is passing tests now https://app.circleci.com/pipelines/github/aweisberg/cassandra?branch=cassandra-18099-trunk

Copy link
Contributor

@maedhroz maedhroz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My feedback is all pretty minor around documentation, import order, etc.

Otherwise, LGTM

@aweisberg aweisberg force-pushed the cassandra-18099-trunk branch 3 times, most recently from 8d04806 to ca2e88e Compare December 13, 2022 00:19
Copy link
Contributor

@dcapwell dcapwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we address the interface comment? Rest are nits

Hint.serializer.serialize(hint, out, descriptor.messagingVersion());
long actualSize = out.position() - startPosition;
checkState(actualSize == hintSize);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have a useful error msg? If this triggers we don't have enough info on what happened

Copy link
Contributor

@dcapwell dcapwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be great to improve the error message of hint, but will leave that as a nit and not a blocker.

+1

@aweisberg aweisberg force-pushed the cassandra-18099-trunk branch 2 times, most recently from b02d470 to 1d0438d Compare December 20, 2022 21:13
patch by Ariel Weisberg; reviewed by David Capwell and Caleb Rackliffe for CASSANDRA-18099
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants