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

MessageServlet assumes TextMessages contain Text

    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

        1. amq-3856_junit.patch
          1 kB
          Alan Hudson
        2. amq-3856.patch
          0.9 kB
          Alan Hudson

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: