diff --git a/org.springframework.integration.http/src/main/java/org/springframework/integration/http/DefaultInboundRequestMapper.java b/org.springframework.integration.http/src/main/java/org/springframework/integration/http/DefaultInboundRequestMapper.java index 9aa06c5417..7b438065b1 100644 --- a/org.springframework.integration.http/src/main/java/org/springframework/integration/http/DefaultInboundRequestMapper.java +++ b/org.springframework.integration.http/src/main/java/org/springframework/integration/http/DefaultInboundRequestMapper.java @@ -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]; } diff --git a/org.springframework.integration.http/src/test/java/org/springframework/integration/http/DefaultInboundRequestMapperTests.java b/org.springframework.integration.http/src/test/java/org/springframework/integration/http/DefaultInboundRequestMapperTests.java index e4e99dd899..3fe184c8ca 100644 --- a/org.springframework.integration.http/src/test/java/org/springframework/integration/http/DefaultInboundRequestMapperTests.java +++ b/org.springframework.integration.http/src/test/java/org/springframework/integration/http/DefaultInboundRequestMapperTests.java @@ -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 message = (Message) mapper.toMessage(request); + assertThat(message.getPayload(), is(content)); + } + }