added ready() check to support empty string
This commit is contained in:
@@ -216,7 +216,7 @@ public class DefaultInboundRequestMapper implements InboundRequestMapper {
|
||||
int bufferLength = (contentLength > -1) ? contentLength : 1024;
|
||||
char[] buffer = new char[bufferLength];
|
||||
int charsRead = 0;
|
||||
while ((charsRead = reader.read(buffer, 0, bufferLength)) != -1) {
|
||||
while (reader.ready() && (charsRead = reader.read(buffer, 0, bufferLength)) != -1) {
|
||||
sb.append(buffer, 0, charsRead);
|
||||
buffer = new char[bufferLength];
|
||||
}
|
||||
|
||||
@@ -70,4 +70,15 @@ public class DefaultInboundRequestMapperTests {
|
||||
assertThat(message.getPayload(), is(content));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyStringTest() throws Exception {
|
||||
String content = "";
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.setContentType("text");
|
||||
byte[] bytes = content.getBytes();
|
||||
request.setContent(bytes);
|
||||
Message<String> message = (Message<String>) mapper.toMessage(request);
|
||||
assertThat(message.getPayload(), is(content));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user