Skip to content

[6.3.x] Fix AMQP Object message decompression (#2256) - #2260

Merged
cshannon merged 2 commits into
apache:activemq-6.3.xfrom
cshannon:backport-2256-6.3.x
Jul 29, 2026
Merged

[6.3.x] Fix AMQP Object message decompression (#2256)#2260
cshannon merged 2 commits into
apache:activemq-6.3.xfrom
cshannon:backport-2256-6.3.x

Conversation

@cshannon

Copy link
Copy Markdown
Contributor

This fixes the AmqpMessageSupport utility to correctly decompress the body of Object Message's in all cases.

Previously the decompression could stop early and not decompress the entire stream of data. This was due to the loop incorrectly casting the read int from the inflater stream as a byte before comparing to -1 to look for end of stream.

This is incorrect because the read() method can return a value between -1 and 255. Java uses Two's Complement to represent signed ints, so if the returned value int is 255 and is cast to a byte it becomes -1. This meant that reading 255 would return -1 leading to the code to exit thinking end of stream has been reached.

(cherry picked from commit 2d60a85)

This fixes the AmqpMessageSupport utility to correctly decompress the
body of Object Message's in all cases.

Previously the decompression could stop early and not decompress the entire stream of
data. This was due to the loop incorrectly casting the read int from the inflater
stream as a byte before comparing to -1 to look for end of stream.

This is incorrect because the read() method can return a value between -1 and 255.
Java uses Two's Complement to represent signed ints, so if the returned value int
is 255 and is cast to a byte it becomes -1. This meant that reading 255 would return -1
leading to the code to exit thinking end of stream has been reached.

(cherry picked from commit 2d60a85)
@cshannon
cshannon merged commit 6463da3 into apache:activemq-6.3.x Jul 29, 2026
19 of 20 checks passed
@cshannon
cshannon deleted the backport-2256-6.3.x branch July 29, 2026 00:30
@github-project-automation github-project-automation Bot moved this from Todo to Done in Apache ActiveMQ v6.3.1 Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Development

Successfully merging this pull request may close these issues.

1 participant