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 <astitc...@apache.org>
Authored: Fri Feb 9 15:05:26 2018 -0500
Committer: Andrew Stitcher <astitc...@apache.org>
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-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org

Reply via email to