diff --git a/core/src/main/java/org/springframework/ws/transport/TransportInputStream.java b/core/src/main/java/org/springframework/ws/transport/TransportInputStream.java index 6569c847..128a2aed 100644 --- a/core/src/main/java/org/springframework/ws/transport/TransportInputStream.java +++ b/core/src/main/java/org/springframework/ws/transport/TransportInputStream.java @@ -30,9 +30,18 @@ import java.util.Iterator; */ public abstract class TransportInputStream extends InputStream { + private InputStream inputStream; + protected TransportInputStream() { } + private InputStream getInputStream() throws IOException { + if (inputStream == null) { + inputStream = createInputStream(); + } + return inputStream; + } + public void close() throws IOException { getInputStream().close(); } @@ -81,7 +90,7 @@ public abstract class TransportInputStream extends InputStream { /** * Returns the input stream to read from. */ - protected abstract InputStream getInputStream() throws IOException; + protected abstract InputStream createInputStream() throws IOException; /** * Returns an iteration over all the header names this request contains. Returns an empty Iterator if diff --git a/core/src/main/java/org/springframework/ws/transport/http/HttpServletTransportInputStream.java b/core/src/main/java/org/springframework/ws/transport/http/HttpServletTransportInputStream.java index 516d54a3..2d456593 100644 --- a/core/src/main/java/org/springframework/ws/transport/http/HttpServletTransportInputStream.java +++ b/core/src/main/java/org/springframework/ws/transport/http/HttpServletTransportInputStream.java @@ -44,7 +44,7 @@ public class HttpServletTransportInputStream extends TransportInputStream { this.httpServletRequest = httpServletRequest; } - protected InputStream getInputStream() throws IOException { + protected InputStream createInputStream() throws IOException { return httpServletRequest.getInputStream(); } diff --git a/core/src/test/java/org/springframework/ws/transport/StubTransportInputStream.java b/core/src/test/java/org/springframework/ws/transport/StubTransportInputStream.java index 4517d0ea..5db01410 100644 --- a/core/src/test/java/org/springframework/ws/transport/StubTransportInputStream.java +++ b/core/src/test/java/org/springframework/ws/transport/StubTransportInputStream.java @@ -37,7 +37,7 @@ public class StubTransportInputStream extends TransportInputStream { this.headers = headers; } - protected InputStream getInputStream() throws IOException { + protected InputStream createInputStream() throws IOException { return inputStream; } diff --git a/core/src/test/java/org/springframework/ws/transport/http/HttpServletTransportInputStreamTest.java b/core/src/test/java/org/springframework/ws/transport/http/HttpServletTransportInputStreamTest.java index 125ad686..2d84e160 100644 --- a/core/src/test/java/org/springframework/ws/transport/http/HttpServletTransportInputStreamTest.java +++ b/core/src/test/java/org/springframework/ws/transport/http/HttpServletTransportInputStreamTest.java @@ -39,7 +39,6 @@ public class HttpServletTransportInputStreamTest extends TestCase { } public void testReadInputStream() throws Exception { - request.setContent(content); byte[] result = FileCopyUtils.copyToByteArray(tis); assertTrue("Invalid contents", Arrays.equals(content, result)); } diff --git a/sandbox/src/main/java/org/springframework/ws/transport/http/HttpUrlConnectionTransportInputStream.java b/sandbox/src/main/java/org/springframework/ws/transport/http/HttpUrlConnectionTransportInputStream.java index 78295e70..6d1035f1 100644 --- a/sandbox/src/main/java/org/springframework/ws/transport/http/HttpUrlConnectionTransportInputStream.java +++ b/sandbox/src/main/java/org/springframework/ws/transport/http/HttpUrlConnectionTransportInputStream.java @@ -67,7 +67,7 @@ public class HttpUrlConnectionTransportInputStream extends TransportInputStream } } - protected InputStream getInputStream() throws IOException { + protected InputStream createInputStream() throws IOException { return connection.getInputStream(); } } diff --git a/sandbox/src/main/java/org/springframework/ws/transport/jms/JmsTransportInputStream.java b/sandbox/src/main/java/org/springframework/ws/transport/jms/JmsTransportInputStream.java index a78ce260..9af1fff7 100644 --- a/sandbox/src/main/java/org/springframework/ws/transport/jms/JmsTransportInputStream.java +++ b/sandbox/src/main/java/org/springframework/ws/transport/jms/JmsTransportInputStream.java @@ -40,7 +40,7 @@ public class JmsTransportInputStream extends TransportInputStream { this.textMessage = textMessage; } - protected InputStream getInputStream() throws IOException { + protected InputStream createInputStream() throws IOException { try { return new ByteArrayInputStream(textMessage.getText().getBytes("UTF-8")); }