Encode AMQP 1.0 arrays of zero-octet elements as opaque values (backport #16994)#16998
Merged
Conversation
## What?
The AMQP 1.0 binary parser (amqp10_binary_parser) decoded an array
whose element constructor has a zero-octet wire encoding (null, true,
false, uint0, ulong0, list0 - wire codes 0x40-0x45) by expanding it
into a full Erlang list, one term per element, via lists:duplicate/2.
It now instead represents such an array as an opaque value ({as_is,
TypeCode, Bin}), the same representation already used for decimal and
NaN/Infinity values that RabbitMQ has no need to interpret further.
## Why
For this class of array, the element count is carried in a small,
fixed-size wire encoding, while the previous implementation allocated
one term per element when decoding it. This meant the memory needed to
hold the decoded value had no relationship to the size of the input
that produced it. Representing the value opaquely removes that
mismatch entirely, rather than merely capping it, and keeps the parser
consistent with how it already treats other value kinds it does not
need to interpret.
(cherry picked from commit 3f0f67d)
Author
|
Tick the box to add this pull request to the merge queue (same as
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What?
The AMQP 1.0 binary parser (amqp10_binary_parser) decoded an array whose element constructor has a zero-octet wire encoding (null, true, false, uint0, ulong0, list0 - wire codes 0x40-0x45) by expanding it into a full Erlang list, one term per element, via lists:duplicate/2. It now instead represents such an array as an opaque value ({as_is, TypeCode, Bin}), the same representation already used for decimal and NaN/Infinity values that RabbitMQ has no need to interpret further.
Why
For this class of array, the element count is carried in a small, fixed-size wire encoding, while the previous implementation allocated one term per element when decoding it. This meant the memory needed to hold the decoded value had no relationship to the size of the input that produced it. Representing the value opaquely removes that mismatch entirely, rather than merely capping it, and keeps the parser consistent with how it already treats other value kinds it does not need to interpret.
Supersedes #16986
This is an automatic backport of pull request #16994 done by Mergify.