From commits-return-43747-archive-asf-public=cust-asf.ponee.io@qpid.apache.org Fri Feb 9 21:14:37 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 34377180654 for ; Fri, 9 Feb 2018 21:14:37 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 23E52160C4C; Fri, 9 Feb 2018 20:14:37 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 6BB5B160C3C for ; Fri, 9 Feb 2018 21:14:36 +0100 (CET) Received: (qmail 5278 invoked by uid 500); 9 Feb 2018 20:14:35 -0000 Mailing-List: contact commits-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@qpid.apache.org Delivered-To: mailing list commits@qpid.apache.org Received: (qmail 5262 invoked by uid 99); 9 Feb 2018 20:14:35 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Feb 2018 20:14:35 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7F66CDFBBB; Fri, 9 Feb 2018 20:14:35 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: astitcher@apache.org To: commits@qpid.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: qpid-proton git commit: PROTON-1754: Emit message group_sequence property as null when possible Date: Fri, 9 Feb 2018 20:14:35 +0000 (UTC) Repository: qpid-proton Updated Branches: refs/heads/master d47ded4ee -> 942085256 PROTON-1754: Emit message group_sequence property as null when possible Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/94208525 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/94208525 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/94208525 Branch: refs/heads/master Commit: 94208525639a74a2187dc7a54fb4979f7d8fe1f8 Parents: d47ded4 Author: Andrew Stitcher Authored: Fri Feb 9 15:05:26 2018 -0500 Committer: Andrew Stitcher Committed: Fri Feb 9 15:05:26 2018 -0500 ---------------------------------------------------------------------- proton-c/src/core/message.c | 9 +++++-- tests/python/proton_tests/message.py | 43 +++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/94208525/proton-c/src/core/message.c ---------------------------------------------------------------------- diff --git a/proton-c/src/core/message.c b/proton-c/src/core/message.c index d890678..c36b466 100644 --- a/proton-c/src/core/message.c +++ b/proton-c/src/core/message.c @@ -813,7 +813,7 @@ int pn_message_data(pn_message_t *msg, pn_data_t *data) pn_data_exit(data); } - err = pn_data_fill(data, "DL[CzSSSCss?t?tSIS]", PROPERTIES, + err = pn_data_fill(data, "DL[CzSSSCss?t?tS?IS]", PROPERTIES, msg->id, pn_string_size(msg->user_id), pn_string_get(msg->user_id), pn_string_get(msg->address), @@ -825,7 +825,12 @@ int pn_message_data(pn_message_t *msg, pn_data_t *data) (bool)msg->expiry_time, msg->expiry_time, (bool)msg->creation_time, msg->creation_time, pn_string_get(msg->group_id), - msg->group_sequence, + /* + * As a heuristic, null out group_sequence if there is no group_id and + * group_sequence is 0. In this case it is extremely unlikely we want + * group semantics + */ + (bool)pn_string_get(msg->group_id) || (bool)msg->group_sequence , msg->group_sequence, pn_string_get(msg->reply_to_group_id)); if (err) return pn_error_format(msg->error, err, "data error: %s", http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/94208525/tests/python/proton_tests/message.py ---------------------------------------------------------------------- diff --git a/tests/python/proton_tests/message.py b/tests/python/proton_tests/message.py index 1be8a73..199f932 100644 --- a/tests/python/proton_tests/message.py +++ b/tests/python/proton_tests/message.py @@ -134,6 +134,7 @@ class CodecTest(Test): assert self.msg.body == msg2.body, (self.msg.body, msg2.body) def testExpiryEncodeAsNull(self): + self.msg.group_id = "A" # Force creation and expiry fields to be present data = self.msg.encode() decoder = Data() @@ -152,6 +153,7 @@ class CodecTest(Test): assert properties[8] == None, properties[8] def testCreationEncodeAsNull(self): + self.msg.group_id = "A" # Force creation and expiry fields to be present data = self.msg.encode() decoder = Data() @@ -169,6 +171,47 @@ class CodecTest(Test): properties = dproperties.value assert properties[9] == None, properties[9] + def testGroupSequenceEncodeAsNull(self): + self.msg.reply_to_group_id = "R" # Force group_id and group_sequence fields to be present + data = self.msg.encode() + + decoder = Data() + + # Skip past the headers + consumed = decoder.decode(data) + decoder.clear() + data = data[consumed:] + + decoder.decode(data) + dproperties = decoder.get_py_described() + # Check we've got the correct described list + assert dproperties.descriptor == 0x73, (dproperties.descriptor) + + properties = dproperties.value + assert properties[10] == None, properties[10] + assert properties[11] == None, properties[11] + + def testGroupSequenceEncodeAsNonNull(self): + self.msg.group_id = "G" + self.msg.reply_to_group_id = "R" # Force group_id and group_sequence fields to be present + data = self.msg.encode() + + decoder = Data() + + # Skip past the headers + consumed = decoder.decode(data) + decoder.clear() + data = data[consumed:] + + decoder.decode(data) + dproperties = decoder.get_py_described() + # Check we've got the correct described list + assert dproperties.descriptor == 0x73, (dproperties.descriptor) + + properties = dproperties.value + assert properties[10] == 'G', properties[10] + assert properties[11] == 0, properties[11] + def testDefaultCreationExpiryDecode(self): # This is a message with everything filled explicitly as null or zero in LIST32 HEADER and PROPERTIES lists data = str2bin('\x00\x53\x70\xd0\x00\x00\x00\x0a\x00\x00\x00\x05\x42\x40\x40\x42\x52\x00\x00\x53\x73\xd0\x00\x00\x00\x12\x00\x00\x00\x0d\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x52\x00\x40') --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org For additional commands, e-mail: commits-help@qpid.apache.org