You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2013/02/19 23:22:05 UTC

svn commit: r1447943 - in /qpid/proton/trunk: proton-c/src/codec/codec.c tests/interop/described_array.amqp tests/python/proton_tests/interop.py

Author: aconway
Date: Tue Feb 19 22:22:05 2013
New Revision: 1447943

URL: http://svn.apache.org/r1447943
Log:
PROTON-232: described arrays seem to force the descriptor to be of the same type as the array

Fixed bug in code.c pn_data_encode_node: was always using the parent->type
for everything inside an array, including the descriptor.

Modified:
    qpid/proton/trunk/proton-c/src/codec/codec.c
    qpid/proton/trunk/tests/interop/described_array.amqp
    qpid/proton/trunk/tests/python/proton_tests/interop.py

Modified: qpid/proton/trunk/proton-c/src/codec/codec.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/codec/codec.c?rev=1447943&r1=1447942&r2=1447943&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/codec/codec.c (original)
+++ qpid/proton/trunk/proton-c/src/codec/codec.c Tue Feb 19 22:22:05 2013
@@ -2095,6 +2095,20 @@ static uint8_t pn_node2code(pn_node_t *n
   }
 }
 
+/* True if node is an element of an array - not the descriptor. */
+static bool pn_is_in_array(pn_data_t *data, pn_node_t *parent, pn_node_t *node) {
+  return (parent && parent->atom.type == PN_ARRAY) /* In array */
+    && !(parent->described && !node->prev); /* Not the descriptor */
+}
+
+/** True if node is the first element of an array, not the descriptor.
+ *@pre pn_is_in_array(data, parent, node)
+ */
+static bool pn_is_first_in_array(pn_data_t *data, pn_node_t *parent, pn_node_t *node) {
+  if (!node->prev) return !parent->described; /* First node */
+  return parent->described && (!pn_data_node(data, node->prev)->prev);
+}
+
 static int pn_data_encode_node(pn_data_t *data, pn_node_t *parent, pn_node_t *node,
                                pn_bytes_t *bytes)
 {
@@ -2103,9 +2117,10 @@ static int pn_data_encode_node(pn_data_t
   uint8_t code;
   conv_t c;
 
-  if (parent && parent->atom.type == PN_ARRAY) {
+  /** In an array we don't write the code before each element, only the first. */
+  if (pn_is_in_array(data, parent, node)) {
     code = pn_type2code(parent->type);
-    if (!node->prev || (node->prev && parent->described && !pn_data_node(data, node->prev)->prev)) {
+    if (pn_is_first_in_array(data, parent, node)) {
       err = pn_i_bytes_writef8(bytes, code);
       if (err) return err;
     }

Modified: qpid/proton/trunk/tests/interop/described_array.amqp
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/interop/described_array.amqp?rev=1447943&r1=1447942&r2=1447943&view=diff
==============================================================================
Files qpid/proton/trunk/tests/interop/described_array.amqp (original) and qpid/proton/trunk/tests/interop/described_array.amqp Tue Feb 19 22:22:05 2013 differ

Modified: qpid/proton/trunk/tests/python/proton_tests/interop.py
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/python/proton_tests/interop.py?rev=1447943&r1=1447942&r2=1447943&view=diff
==============================================================================
--- qpid/proton/trunk/tests/python/proton_tests/interop.py (original)
+++ qpid/proton/trunk/tests/python/proton_tests/interop.py Tue Feb 19 22:22:05 2013
@@ -103,7 +103,6 @@ class InteropTest(common.Test):
         assert self.data.next() is None
 
     def test_described_array(self):
-        raise common.Skipped()  # PROTON-240: Incorrect encoding of described arrays.
         self.decode("described_array")
         self.assert_next(Data.ARRAY, Array("int-array", Data.INT, *range(0,10)))
 



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