-
Notifications
You must be signed in to change notification settings - Fork 613
simplify WriteShortstr #845
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
simplify WriteShortstr #845
Conversation
Thank you! |
simplify WriteShortstr (cherry picked from commit fb8e1f2)
Shall I open an issue for this or is this "as designed"? |
An AMQP shortstr value can only contain 256 bytes: https://www.rabbitmq.com/amqp-0-9-1-reference.html#domain.shortstr |
Yes, that I understand, but the current code does the following for payload all 'A':
So when you read it back, it reads wrong values (due to the wrong ones sent). There is nowhere a prevention built in to not being able to send more than 255 chars. |
We should fail early and visibly so yes @bollhals, this is worth changing, even though this is how the protocol is designed and not really a bug. |
Backported to |
Proposed Changes
Simplifying write of string values. GetBytes returns the number of bytes written, so there is no need to precalculate the length.
Types of Changes
Checklist
Put an
x
in the boxes that apply. You can also fill these out after creatingthe PR. If you're unsure about any of them, don't hesitate to ask on the
mailing list. We're here to help! This is simply a reminder of what we are
going to look for before merging your code.
CONTRIBUTING.md
documentFurther Comments
Question: There is a bug in the code (before this and also after this) that if you write a string resulting in more than 255 bytes, the length variable (byte) will be cut off and the resulting deserialized value will be different from the source. Shall I open an issue for this?