Skip to content

[6.2.x] Fix AMQP Object message decompression (#2256) - #2263

Merged
cshannon merged 1 commit into
apache:activemq-6.2.xfrom
cshannon:backport-2245-6.2.x
Jul 29, 2026
Merged

[6.2.x] Fix AMQP Object message decompression (#2256)#2263
cshannon merged 1 commit into
apache:activemq-6.2.xfrom
cshannon:backport-2245-6.2.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 self-assigned this Jul 28, 2026
@cshannon
cshannon merged commit e265abf into apache:activemq-6.2.x Jul 29, 2026
3 of 4 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Apache ActiveMQ v6.2.9 Jul 29, 2026
@cshannon
cshannon deleted the backport-2245-6.2.x branch July 29, 2026 00:30
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