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)