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

MessageServlet assumes TextMessages contain Text

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.5.1, 5.6.0
    • Fix Version/s: 5.7.0
    • Component/s: Broker
    • Labels:
      None
    • Environment:

      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

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

              Dates

              • Created:
                Updated:
                Resolved: