qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r1482795 - in /qpid/trunk/qpid/cpp/src: qpid/broker/amqp/Translation.cpp tests/interlink_tests.py
Date Wed, 15 May 2013 12:48:34 GMT
Author: gsim
Date: Wed May 15 12:48:34 2013
New Revision: 1482795

URL: http://svn.apache.org/r1482795
Log:
QPID-4846: prevent assertion when translating empty 0-10 message content into 1.0

Modified:
    qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Translation.cpp
    qpid/trunk/qpid/cpp/src/tests/interlink_tests.py

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Translation.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Translation.cpp?rev=1482795&r1=1482794&r2=1482795&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Translation.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Translation.cpp Wed May 15 12:48:34 2013
@@ -230,7 +230,7 @@ void Translation::write(OutgoingFromQueu
             qpid::amqp::MessageEncoder encoder(&buffer[0], buffer.size());
             encoder.writeProperties(properties);
             encoder.writeApplicationProperties(applicationProperties);
-            encoder.writeBinary(content, &qpid::amqp::message::DATA);
+            if (content.size()) encoder.writeBinary(content, &qpid::amqp::message::DATA);
             out.write(&buffer[0], encoder.getPosition());
         } else {
             QPID_LOG(error, "Could not write message data in AMQP 1.0 format");

Modified: qpid/trunk/qpid/cpp/src/tests/interlink_tests.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/interlink_tests.py?rev=1482795&r1=1482794&r2=1482795&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/interlink_tests.py (original)
+++ qpid/trunk/qpid/cpp/src/tests/interlink_tests.py Wed May 15 12:48:34 2013
@@ -107,6 +107,37 @@ class AmqpBrokerTest(BrokerTest):
     def test_translate2(self):
         self.send_and_receive(send_config=Config(self.broker, version="amqp0-10"))
 
+    def send_and_receive_empty(self, send_config=None, recv_config=None):
+        sconfig = send_config or self.default_config
+        rconfig = recv_config or self.default_config
+        send_cmd = ["qpid-send",
+               "--broker", sconfig.url,
+               "--address=%s" % sconfig.address,
+               "--connection-options={protocol:%s}" % sconfig.version,
+               "--content-size=0",
+               "--messages=1",
+               "-P", "my-header=abc"
+               ]
+        sender = self.popen(send_cmd)
+        sender.wait()
+        receive_cmd = ["qpid-receive",
+               "--broker", rconfig.url,
+               "--address=%s" % rconfig.address,
+               "--connection-options={protocol:%s}" % rconfig.version,
+               "--messages=1",
+               "--print-content=false", "--print-headers=true"
+               ]
+        receiver = self.popen(receive_cmd, stdout=PIPE)
+        l = receiver.stdout.read()
+        assert "my-header:abc" in l
+        receiver.wait()
+
+    def test_translate_empty_1(self):
+        self.send_and_receive_empty(recv_config=Config(self.broker, version="amqp0-10"))
+
+    def test_translate_empty_2(self):
+        self.send_and_receive_empty(send_config=Config(self.broker, version="amqp0-10"))
+
     def test_domain(self):
         brokerB = self.amqp_broker()
         self.agent.create("domain", "BrokerB", {"url":brokerB.host_port()})



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


Mime
View raw message