Pavel Moravec created QPID-7134:
-----------------------------------

             Summary: [C++ client] Message::setContent("") does not work
                 Key: QPID-7134
                 URL: https://issues.apache.org/jira/browse/QPID-7134
             Project: Qpid
          Issue Type: Bug
          Components: C++ Client
    Affects Versions: qpid-cpp-0.34
            Reporter: Pavel Moravec
            Assignee: Gordon Sim


Message::setContent internally updates just "bytes" property of the Message 
object but not the "content" object. That brings problems when trying to reset 
content to empty one - original content is still stored in "content" object 
property and e.g. an attempt to send this "empty" message sends the message 
with original content.

Reproducer (outside a broker, feel free to add receiving initial message from 
the broker, or sending the result to it back):

{noformat}
#include <iostream>
#include <qpid/messaging/Message.h>

using namespace std;
using namespace qpid::messaging;

int main(int argc, char* argv[])
{
    qpid::types::Variant content("some content");
    Message m1(content);
    cout << "Message 1: initial content set to \"" << m1.getContent() << "\", 
contentSize = " << m1.getContentSize() << endl;
    m1.setContent("message 1");
    cout << "Message 1: after content set to \"" << m1.getContent() << "\", 
contentSize = " << m1.getContentSize() << endl;
    m1.setContent(std::string());
    cout << "Message 1: after content set to an empty string, the content is 
still \"" << m1.getContent() << "\" and contentSize = " << m1.getContentSize() 
<< endl;

    return 0;
}
{noformat}

That returns:

{noformat}
Message 1: initial content set to "some content", contentSize = 12
Message 1: after content set to "message 1", contentSize = 9
Message 1: after content set to an empty string, the content is still "some 
content" and contentSize = 12
{noformat}

See "some content" of size 12 returned after an attempt to empty the message 
content. See it is the _original_ content before first setContent called.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org
For additional commands, e-mail: dev-h...@qpid.apache.org

Reply via email to