You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Alan Hudson (JIRA)" <ji...@apache.org> on 2012/05/28 19:45:23 UTC

[jira] [Comment Edited] (AMQ-3856) MessageServlet assumes TextMessages contain Text

    [ https://issues.apache.org/jira/browse/AMQ-3856?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13284474#comment-13284474 ] 

Alan Hudson edited comment on AMQ-3856 at 5/28/12 5:43 PM:
-----------------------------------------------------------

Patches are easy I'll get those together.  Best I can tell the activemq-web module does not contain any junit tests?  or at least the src/test directory doesn't exist as in other modules.  Fairly new to coding in ActiveMQ so perhaps they are located some place else?

It's possible the right place for these tests is in activemq-web-demo/src/test?  I see some reading tests but no POST requests.  If that's the right place then I'll work up some POST examples.  

I've confirmed that's the right place for the tests and have developed a test showing the problem.  I'll attach the diff.
                
      was (Author: giles7777):
    Patches are easy I'll get those together.  Best I can tell the activemq-web module does not contain any junit tests?  or at least the src/test directory doesn't exist as in other modules.  Fairly new to coding in ActiveMQ so perhaps they are located some place else?

It's possible the right place for these tests is in activemq-web-demo/src/test?  I see some reading tests but no POST requests.  If that's the right place then I'll work up some POST examples.  
                  
> MessageServlet assumes TextMessages contain Text
> ------------------------------------------------
>
>                 Key: AMQ-3856
>                 URL: https://issues.apache.org/jira/browse/AMQ-3856
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.5.1, 5.6.0
>         Environment: all
>            Reporter: Alan Hudson
>             Fix For: 5.7.0
>
>
> 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());
>         }
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira