You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Timothy Bish (JIRA)" <ji...@apache.org> on 2016/04/12 20:30:25 UTC
[jira] [Commented] (AMQ-6232) Additional '\n' added when
publishing messages through RESTful API
[ https://issues.apache.org/jira/browse/AMQ-6232?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15237709#comment-15237709 ]
Timothy Bish commented on AMQ-6232:
-----------------------------------
We welcome patches with tests, if you want to take a shot at fixing it.
> 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)