Revised ByteArrayOutputStream handling in MarshallingView and co

Issue: SPR-11646
This commit is contained in:
Juergen Hoeller
2014-04-02 20:57:09 +02:00
parent 3a96f16654
commit 8006696613
3 changed files with 10 additions and 12 deletions

View File

@@ -267,7 +267,7 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter
}
if (isIncludePayload() && request instanceof RequestCachingRequestWrapper) {
RequestCachingRequestWrapper wrapper = (RequestCachingRequestWrapper) request;
byte[] buf = wrapper.toByteArray();
byte[] buf = wrapper.getContentAsByteArray();
if (buf.length > 0) {
int length = Math.min(buf.length, getMaxPayloadLength());
String payload;
@@ -304,7 +304,7 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter
private static class RequestCachingRequestWrapper extends HttpServletRequestWrapper {
private final ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
private final ByteArrayOutputStream cachedContent = new ByteArrayOutputStream(1024);
private final ServletInputStream inputStream;
@@ -334,8 +334,8 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter
return this.reader;
}
private byte[] toByteArray() {
return this.bos.toByteArray();
private byte[] getContentAsByteArray() {
return this.cachedContent.toByteArray();
}
@@ -351,7 +351,7 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter
public int read() throws IOException {
int ch = this.is.read();
if (ch != -1) {
bos.write(ch);
cachedContent.write(ch);
}
return ch;
}