This is an automated email from the ASF dual-hosted git repository. kpvdr pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/qpid-interop-test.git
commit ebb35df87a970f84ced4c070b6bf900b2ad39c60 Author: QIT Development Team <[email protected]> AuthorDate: Mon Aug 3 10:31:51 2026 -0400 Fix BytesMessage and Message interop failures across 4 shims - Python/JS receivers: handle non-bytes/Buffer body from JMS Data section - .NET receiver: return empty bytes for null BytesMessage body - JS sender: omit body for null type (Rhea encodes null as AmqpValue) - JMS receiver: use GsonBuilder().serializeNulls() to preserve null values - Test harness: defensive .get("value") in compare_messages Co-Authored-By: Claude Opus 4.6 <[email protected]> --- shims/dotnet-proton/src/Receiver.cs | 1 + .../src/main/java/org/apache/qpid/qit/JmsReceiver.java | 3 ++- shims/javascript-rhea/shim.js | 11 +++++++---- shims/python-proton/shim.py | 8 +++++--- tests/test_jms_unified.py | 4 ++-- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/shims/dotnet-proton/src/Receiver.cs b/shims/dotnet-proton/src/Receiver.cs index b541c25..a239fb5 100644 --- a/shims/dotnet-proton/src/Receiver.cs +++ b/shims/dotnet-proton/src/Receiver.cs @@ -128,6 +128,7 @@ namespace Qit.Shim Value = BitConverter.ToString(bytes).Replace("-", "").ToLower() }; } + return new DecodedMessage { Type = "bytes", Value = "" }; } else if (jmsType == JMS_MESSAGE) { diff --git a/shims/java-qpid-jms/src/main/java/org/apache/qpid/qit/JmsReceiver.java b/shims/java-qpid-jms/src/main/java/org/apache/qpid/qit/JmsReceiver.java index aa05388..06e9be7 100644 --- a/shims/java-qpid-jms/src/main/java/org/apache/qpid/qit/JmsReceiver.java +++ b/shims/java-qpid-jms/src/main/java/org/apache/qpid/qit/JmsReceiver.java @@ -1,6 +1,7 @@ package org.apache.qpid.qit; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; import com.google.gson.JsonObject; @@ -75,7 +76,7 @@ public class JmsReceiver { consumer = session.createConsumer(destination); // Receive messages - Gson gson = new Gson(); + Gson gson = new GsonBuilder().serializeNulls().create(); JsonArray messages = new JsonArray(); long timeoutMs = timeout * 1000L; diff --git a/shims/javascript-rhea/shim.js b/shims/javascript-rhea/shim.js index 36e83bf..78bd08f 100755 --- a/shims/javascript-rhea/shim.js +++ b/shims/javascript-rhea/shim.js @@ -83,10 +83,11 @@ function decodeJmsMessage(body, jmsMsgType) { }; } else if (jmsMsgType === JMS_BYTES_MESSAGE) { // BytesMessage: body is binary in Data section - if (Buffer.isBuffer(body)) { - return { type: 'bytes', value: body.toString('hex') }; + if (body === null || body === undefined) { + return { type: 'bytes', value: '' }; } - return { type: 'bytes', value: null }; + const buf = Buffer.isBuffer(body) ? body : Buffer.from(body); + return { type: 'bytes', value: buf.toString('hex') }; } else if (jmsMsgType === JMS_MESSAGE) { // Empty message return { type: 'null', value: null }; @@ -414,8 +415,10 @@ function send(options) { const message = { message_id: msgData.index, - body: body }; + if (body !== null && body !== undefined) { + message.body = body; + } // Add JMS annotations if in JMS mode if (jmsMode) { diff --git a/shims/python-proton/shim.py b/shims/python-proton/shim.py index b978cf5..29eeb81 100755 --- a/shims/python-proton/shim.py +++ b/shims/python-proton/shim.py @@ -262,9 +262,11 @@ class ReceiverHandler(MessagingHandler): elif jms_msg_type == JMS_BYTES_MESSAGE: # BytesMessage: body is binary in Data section body_val = msg.body - if isinstance(body_val, bytes): - return {"index": msg_index, "type": "bytes", "value": body_val.hex()} - return {"index": msg_index, "type": "bytes", "value": None} + if body_val is None: + return {"index": msg_index, "type": "bytes", "value": ""} + if not isinstance(body_val, bytes): + body_val = bytes(body_val) + return {"index": msg_index, "type": "bytes", "value": body_val.hex()} elif jms_msg_type == JMS_MESSAGE: # Empty message return {"index": msg_index, "type": "null", "value": None} diff --git a/tests/test_jms_unified.py b/tests/test_jms_unified.py index 927f10f..ef25fb8 100644 --- a/tests/test_jms_unified.py +++ b/tests/test_jms_unified.py @@ -360,8 +360,8 @@ def compare_messages(sent: list[dict], received: list[dict], sender: str, receiv f"sent {s['type']}, received {r['type']}" ) - sent_value = normalize_value(s["type"], s["value"]) - recv_value = normalize_value(r["type"], r["value"]) + sent_value = normalize_value(s["type"], s.get("value")) + recv_value = normalize_value(r["type"], r.get("value")) assert sent_value == recv_value, ( f"{sender}→{receiver}: Message {i} value mismatch - " --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
