This is an automated email from the ASF dual-hosted git repository.
tabish121 pushed a commit to branch 1.x
in repository https://gitbox.apache.org/repos/asf/qpid-protonj2.git
The following commit(s) were added to refs/heads/1.x by this push:
new 4555443e PROTON-3001 Fix read of Sym8 Symbols from the stream decoder
4555443e is described below
commit 4555443e308991d968ef6d73571dedb8276088fe
Author: Timothy Bish <[email protected]>
AuthorDate: Tue Nov 3 17:25:24 2026 -0500
PROTON-3001 Fix read of Sym8 Symbols from the stream decoder
Correctly mask the size byte when casting to int on the read from the
decoder to avoid a decode exception
(cherry picked from commit 14c0946daf5502ef587c8f80ca6a06b64ef78c81)
---
.../decoders/primitives/Symbol8TypeDecoder.java | 2 +-
.../codec/primitives/SymbolTypeCodecTest.java | 39 ++++++++++++++++++++++
2 files changed, 40 insertions(+), 1 deletion(-)
diff --git
a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/primitives/Symbol8TypeDecoder.java
b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/primitives/Symbol8TypeDecoder.java
index 06299151..84a9ad78 100644
---
a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/primitives/Symbol8TypeDecoder.java
+++
b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/primitives/Symbol8TypeDecoder.java
@@ -44,6 +44,6 @@ public final class Symbol8TypeDecoder extends
AbstractSymbolTypeDecoder {
@Override
public int readSize(InputStream stream, StreamDecoderState state) throws
DecodeException {
- return ProtonStreamUtils.readByte(stream);
+ return ProtonStreamUtils.readByte(stream) & 0xff;
}
}
diff --git
a/protonj2/src/test/java/org/apache/qpid/protonj2/codec/primitives/SymbolTypeCodecTest.java
b/protonj2/src/test/java/org/apache/qpid/protonj2/codec/primitives/SymbolTypeCodecTest.java
index ccd756e0..40018ebb 100644
---
a/protonj2/src/test/java/org/apache/qpid/protonj2/codec/primitives/SymbolTypeCodecTest.java
+++
b/protonj2/src/test/java/org/apache/qpid/protonj2/codec/primitives/SymbolTypeCodecTest.java
@@ -713,4 +713,43 @@ public class SymbolTypeCodecTest extends CodecTestSupport {
assertEquals(Symbol.class, typeDecoder.getTypeClass());
assertThrows(DecodeException.class, () ->
typeDecoder.skipValue(buffer, decoderState));
}
+
+ @Test
+ public void testDecodeSymbol8WithFullSizeEncoded() throws IOException {
+ doTestDecodeSymbol8WithFullSizeEncoded(false);
+ }
+
+ @Test
+ public void testDecodeSymbol8WithFullSizeEncodedFS() throws IOException {
+ doTestDecodeSymbol8WithFullSizeEncoded(true);
+ }
+
+ private void doTestDecodeSymbol8WithFullSizeEncoded(boolean fromStream)
throws IOException {
+ ProtonBuffer buffer =
ProtonBufferAllocator.defaultAllocator().allocate();
+
+ final byte[] payload = new byte[255];
+
+ random.nextBytes(payload);
+
+ buffer.writeByte(EncodingCodes.SYM8);
+ buffer.writeByte((byte) 255);
+ buffer.writeBytes(payload);
+
+ final Symbol result;
+
+ if (fromStream) {
+ InputStream stream = new ProtonBufferInputStream(buffer.copy());
+ result = streamDecoder.readSymbol(stream, streamDecoderState);
+ } else {
+ result = decoder.readSymbol(buffer.copy(), decoderState);
+ }
+
+ buffer.advanceReadOffset(2); // Skip the encoding code and size
+
+ final ProtonBuffer bytes =
ProtonBufferAllocator.defaultAllocator().allocate();
+
+ result.writeTo(bytes);
+
+ assertEquals(bytes, buffer);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]