forked from rabbitmq/rabbitmq-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse 2 bytes encoded AMQP boolean to Erlang boolean
An AMQP boolean can by encoded using 1 byte or 2 bytes: https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-boolean Prior to this commit, our Erlang parser returned: * Erlang terms `true` or `false` for the 1 byte AMQP encoding * Erlang terms `{boolean, true}` or `{boolean, false}` for the 2 byte AMQP enconding Having a serializer and parser that perform the opposite actions such that ``` Term = parse(serialize(Term)) ``` is desirable as it provides a symmetric property useful not only for property based testing, but also for avoiding altering message hashes when serializing and parsing the same term. However, dealing wth `{boolean, boolean()}` tuples instead of `boolean()` is very unhandy since all Erlang code must take care of both forms leading to subtle bugs as occurred in: * https://github.com/rabbitmq/rabbitmq-server/blob/4cbeab897471fb55f1f0da02dbd178553370abe0/deps/rabbitmq_amqp1_0/src/rabbit_amqp1_0_message.erl#L155-L158 * https://github.com/rabbitmq/rabbitmq-server/blob/b8173c9d3b0e906d6d523c5eb6e4e75b4870b921/deps/rabbitmq_mqtt/src/mc_mqtt.erl#L83-L88 * https://github.com/rabbitmq/rabbitmq-server/blob/b8173c9d3b0e906d6d523c5eb6e4e75b4870b921/deps/rabbit/src/mc_amqpl.erl#L123-L127 Therefore, this commits decides to take the safe approach and always parse to an Erlang `boolean()` independent of whether the AMQP boolean was encoded with 1 or 2 bytes.
- Loading branch information
Showing
10 changed files
with
47 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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