activemq-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ding Jinqiang (JIRA)" <j...@apache.org>
Subject [jira] [Created] (AMQ-6232) Additional '\n' added when publishing messages through RESTful API
Date Fri, 08 Apr 2016 08:45:25 GMT
Ding Jinqiang created AMQ-6232:
----------------------------------

             Summary: Additional  '\n' added when publishing messages through RESTful API
                 Key: AMQ-6232
                 URL: https://issues.apache.org/jira/browse/AMQ-6232
             Project: ActiveMQ
          Issue Type: Bug
    Affects Versions: 5.13.2
            Reporter: Ding Jinqiang


I think there's a problem in reading post body in org.apache.activemq.web.MessageServletSupport#getPostedMessageBody:

{code:title=MessageServletSupport.java|borderStyle=solid}
 /**
     * @return the text that was posted to the servlet which is used as the body
     *         of the message to be sent
     */
    protected String getPostedMessageBody(HttpServletRequest request) throws IOException {
        String answer = request.getParameter(bodyParameter);
        String contentType = request.getContentType();
        if (answer == null && contentType != null) {
            LOG.debug("Content-Type={}", contentType);
            // lets read the message body instead
            BufferedReader reader = request.getReader();
            StringBuffer buffer = new StringBuffer();   //BTW, StringBuilder is a better choice?
            while (true) {
                String line = reader.readLine();  //shouldn't using readLine
                if (line == null) {
                    break;
                }
                buffer.append(line);
                buffer.append("\n");    // additional '\n' added when last line doesn't end
with '\n'
            }
            return buffer.toString();
        }
        return answer;
    }
{code}




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message