Uploaded image for project: 'ActiveMQ Classic'
  1. ActiveMQ Classic
  2. AMQ-3856

MessageServlet assumes TextMessages contain Text

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.5.1, 5.6.0
    • 5.7.0
    • Broker
    • None
    • all

    Description

      writeMessageResponse assumes that a text message will contain non null text. It does a txt.startsWith which crashes with TextMessages with no body.

      It can be fixed with this code:

      protected void writeMessageResponse(PrintWriter writer, Message message) throws JMSException, IOException {
      if (message instanceof TextMessage) {
      TextMessage textMsg = (TextMessage)message;
      String txt = textMsg.getText();

      if (txt != null) {
      if (txt.startsWith("<?"))

      { txt = txt.substring(txt.indexOf("?>") + 2); }

      writer.print(txt);
      }
      } else if (message instanceof ObjectMessage)

      { ObjectMessage objectMsg = (ObjectMessage)message; Object object = objectMsg.getObject(); writer.print(object.toString()); }

      }

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            tabish Timothy A. Bish
            giles7777 Alan Hudson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment