Uploaded image for project: 'Qpid'
  1. Qpid
  2. QPID-7134

[C++ client] Message::setContent("") does not work

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • qpid-cpp-0.34
    • qpid-cpp-1.35.0
    • C++ Client
    • None

    Description

      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):

      #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;
      }
      

      That returns:

      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
      

      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.

      Attachments

        Activity

          People

            gsim Gordon Sim
            pmoravec Pavel Moravec
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: