You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2018/02/01 22:58:50 UTC

[1/3] qpid-proton git commit: PROTON-1505: Fix encoding and decoding of message priority - Added missing default message header fields to xml - Fixed decoder to set priority to default of not set rather than 0 - Fixed encoder to not set priority if it is

Repository: qpid-proton
Updated Branches:
  refs/heads/master 61073481b -> c6bfeff2a


PROTON-1505: Fix encoding and decoding of message priority
- Added missing default message header fields to xml
- Fixed decoder to set priority to default of not set rather than 0
- Fixed encoder to not set priority if it is default
- Added tests for encoding/decoding


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/c6bfeff2
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/c6bfeff2
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/c6bfeff2

Branch: refs/heads/master
Commit: c6bfeff2a22f3e9495140df3cef046d6708cf5c1
Parents: 21d5024
Author: Andrew Stitcher <as...@apache.org>
Authored: Thu Jan 25 01:59:18 2018 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Thu Feb 1 17:39:35 2018 -0500

----------------------------------------------------------------------
 proton-c/src/core/message.c          | 27 ++++++++++++++++--------
 proton-c/src/messaging.xml           |  8 ++++----
 tests/python/proton_tests/message.py | 34 +++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c6bfeff2/proton-c/src/core/message.c
----------------------------------------------------------------------
diff --git a/proton-c/src/core/message.c b/proton-c/src/core/message.c
index 548636b..15b6dea 100644
--- a/proton-c/src/core/message.c
+++ b/proton-c/src/core/message.c
@@ -114,7 +114,7 @@ int pn_message_inspect(void *obj, pn_string_t *dst)
     comma = true;
   }
 
-  if (msg->priority != PN_DEFAULT_PRIORITY) {
+  if (msg->priority != HEADER_PRIORITY_DEFAULT) {
     err = pn_string_addf(dst, "priority=%i, ", msg->priority);
     if (err) return err;
     comma = true;
@@ -309,7 +309,7 @@ static pn_message_t *pni_message_new(size_t size)
   static const pn_class_t clazz = PN_CLASS(pn_message);
   pn_message_t *msg = (pn_message_t *) pn_class_new(&clazz, size);
   msg->durable = false;
-  msg->priority = PN_DEFAULT_PRIORITY;
+  msg->priority = HEADER_PRIORITY_DEFAULT;
   msg->ttl = 0;
   msg->first_acquirer = false;
   msg->delivery_count = 0;
@@ -364,7 +364,7 @@ void pn_message_free(pn_message_t *msg)
 void pn_message_clear(pn_message_t *msg)
 {
   msg->durable = false;
-  msg->priority = PN_DEFAULT_PRIORITY;
+  msg->priority = HEADER_PRIORITY_DEFAULT;
   msg->ttl = 0;
   msg->first_acquirer = false;
   msg->delivery_count = 0;
@@ -672,12 +672,20 @@ int pn_message_decode(pn_message_t *msg, const char *bytes, size_t size)
     pn_data_next(msg->data);
 
     switch (desc) {
-    case HEADER:
-      err = pn_data_scan(msg->data, "D.[oBIoI]", &msg->durable, &msg->priority,
-                   &msg->ttl, &msg->first_acquirer, &msg->delivery_count);
+    case HEADER: {
+      bool priority_q;
+      uint8_t priority;
+      err = pn_data_scan(msg->data, "D.[o?BIoI]",
+                         &msg->durable,
+                         &priority_q, &priority,
+                         &msg->ttl,
+                         &msg->first_acquirer,
+                         &msg->delivery_count);
       if (err) return pn_error_format(msg->error, err, "data error: %s",
                                       pn_error_text(pn_data_error(msg->data)));
+      msg->priority = priority_q ? priority : HEADER_PRIORITY_DEFAULT;
       break;
+    }
     case PROPERTIES:
       {
         pn_bytes_t user_id, address, subject, reply_to, ctype, cencoding,
@@ -771,8 +779,11 @@ int pn_message_encode(pn_message_t *msg, char *bytes, size_t *size)
 int pn_message_data(pn_message_t *msg, pn_data_t *data)
 {
   pn_data_clear(data);
-  int err = pn_data_fill(data, "DL[oB?IoI]", HEADER, msg->durable,
-                         msg->priority, msg->ttl, msg->ttl, msg->first_acquirer,
+  int err = pn_data_fill(data, "DL[o?B?IoI]", HEADER,
+                         msg->durable,
+                         msg->priority!=HEADER_PRIORITY_DEFAULT, msg->priority,
+                         msg->ttl, msg->ttl,
+                         msg->first_acquirer,
                          msg->delivery_count);
   if (err)
     return pn_error_format(msg->error, err, "data error: %s",

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c6bfeff2/proton-c/src/messaging.xml
----------------------------------------------------------------------
diff --git a/proton-c/src/messaging.xml b/proton-c/src/messaging.xml
index 01c34e7..1feb03b 100644
--- a/proton-c/src/messaging.xml
+++ b/proton-c/src/messaging.xml
@@ -36,11 +36,11 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   <section name="message-format">
     <type name="header" class="composite" source="list" provides="section">
       <descriptor name="amqp:header:list" code="0x00000000:0x00000070"/>
-      <field name="durable" type="boolean"/>
-      <field name="priority" type="ubyte"/>
+      <field name="durable" type="boolean" default="false"/>
+      <field name="priority" type="ubyte" default="4"/>
       <field name="ttl" type="milliseconds"/>
-      <field name="first-acquirer" type="boolean"/>
-      <field name="delivery-count" type="uint"/>
+      <field name="first-acquirer" type="boolean" default="false"/>
+      <field name="delivery-count" type="uint" default="0"/>
     </type>
     <type name="delivery-annotations" class="restricted" source="annotations" provides="section">
       <descriptor name="amqp:delivery-annotations:map" code="0x00000000:0x00000071"/>

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c6bfeff2/tests/python/proton_tests/message.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/message.py b/tests/python/proton_tests/message.py
index 550520e..a7f1dad 100644
--- a/tests/python/proton_tests/message.py
+++ b/tests/python/proton_tests/message.py
@@ -132,3 +132,37 @@ class CodecTest(Test):
     assert self.msg.address == msg2.address, (self.msg.address, msg2.address)
     assert self.msg.subject == msg2.subject, (self.msg.subject, msg2.subject)
     assert self.msg.body == msg2.body, (self.msg.body, msg2.body)
+
+  def testDefaultPriorityEncodeAndDecode(self):
+    assert self.msg.priority == 4, (self.msg.priority)
+    self.msg.ttl = 0.003 # field after priority, so forces priority to be present
+    data = self.msg.encode()
+
+    decoder = Data()
+    decoder.decode(data)
+
+    dheaders = decoder.get_py_described()
+    # Check we've got the correct described list
+    assert dheaders.descriptor == 0x70, (dheaders.descriptor)
+
+    # Check that the priority field (second field) is encoded as null
+    headers = dheaders.value
+    assert headers[1] == None, (headers[1])
+
+    # 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\x22\x00\x00\x00\x0d\x40\x40\x40\x40\x40\x40\x40\x40\x83\x00\x00\x00\x00\x00\x00\x00\x00\x83\x00\x00\x00\x00\x00\x00\x00\x00\x40\x52\x00\x40')
+    msg2 = Message()
+    msg2.decode(data)
+    assert msg2.priority == 4, (msg2.priority)
+
+    # The same message with LIST8s instead
+    data = str2bin('\x00\x53\x70\xc0\x07\x05\x42\x40\x40\x42\x52\x00\x00\x53\x73\xc0\x1f\x0d\x40\x40\x40\x40\x40\x40\x40\x40\x83\x00\x00\x00\x00\x00\x00\x00\x00\x83\x00\x00\x00\x00\x00\x00\x00\x00\x40\x52\x00\x40')
+    msg3 = Message()
+    msg3.decode(data)
+    assert msg3.priority == 4, (msg3.priority)
+
+    # Minified message with zero length HEADER and PROPERTIES lists
+    data = str2bin('\x00\x53\x70\x45' '\x00\x53\x73\x45')
+    msg4 = Message()
+    msg4.decode(data)
+    assert msg4.priority == 4, (msg4.priority)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[3/3] qpid-proton git commit: NO-JIRA: Fixed typo in old ruby example test driver (misspelled /usr/bin/env)

Posted by as...@apache.org.
NO-JIRA: Fixed typo in old ruby example test driver (misspelled /usr/bin/env)


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/d2097dcb
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/d2097dcb
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/d2097dcb

Branch: refs/heads/master
Commit: d2097dcb67a890e8a3f8c7a5a457619837d9c25c
Parents: 6107348
Author: Andrew Stitcher <as...@apache.org>
Authored: Thu Feb 1 17:38:21 2018 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Thu Feb 1 17:39:35 2018 -0500

----------------------------------------------------------------------
 proton-c/bindings/ruby/tests/old_examples/old_example_test.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d2097dcb/proton-c/bindings/ruby/tests/old_examples/old_example_test.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/old_examples/old_example_test.rb b/proton-c/bindings/ruby/tests/old_examples/old_example_test.rb
index e8b21d2..53a6757 100755
--- a/proton-c/bindings/ruby/tests/old_examples/old_example_test.rb
+++ b/proton-c/bindings/ruby/tests/old_examples/old_example_test.rb
@@ -1,4 +1,4 @@
-#!/usr/bin/enc ruby
+#!/usr/bin/env ruby
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[2/3] qpid-proton git commit: PROTON-1753: Improve protocol.h generator to include some useful default field values

Posted by as...@apache.org.
PROTON-1753: Improve protocol.h generator to include some useful default field values


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/21d50246
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/21d50246
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/21d50246

Branch: refs/heads/master
Commit: 21d5024675a6c9acf621ed797c4bc303c263c22d
Parents: d2097dc
Author: Andrew Stitcher <as...@apache.org>
Authored: Thu Jan 25 01:58:30 2018 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Thu Feb 1 17:39:35 2018 -0500

----------------------------------------------------------------------
 proton-c/src/protocol.h.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/21d50246/proton-c/src/protocol.h.py
----------------------------------------------------------------------
diff --git a/proton-c/src/protocol.h.py b/proton-c/src/protocol.h.py
index 0f58906..321cf64 100644
--- a/proton-c/src/protocol.h.py
+++ b/proton-c/src/protocol.h.py
@@ -34,6 +34,17 @@ for type in TYPES:
   for f in type.query["field"]:
     print("#define %s_%s (%s)" % (field_kw(type), field_kw(f), fidx))
     fidx += 1
+    d = f["@default"]
+    if d:
+        ft = ftype(f)
+        # Don't bother to emit a boolean default that is False
+        if ft=="boolean" and d=="false": continue
+        # Don't output non numerics unless symbol
+        # We should really fully resolve to actual restricted value
+        # this is really true for symbols too which accidentally work
+        if ft=="symbol": d = '"' + d + '"'
+        elif d[0] not in '0123456789': continue
+        print("#define %s_%s_DEFAULT (%s) /* %s */" % (field_kw(type), field_kw(f), d, ft))
 
 idx = 0
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org