Skip to content

Commit f9167c3

Browse files
committed
Improve Javadoc of ContentCachingRequestWrapper
Closes gh-27068
1 parent fbf4724 commit f9167c3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

spring-web/src/main/java/org/springframework/web/util/ContentCachingRequestWrapper.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,9 +40,15 @@
4040
* the {@linkplain #getInputStream() input stream} and {@linkplain #getReader() reader},
4141
* and allows this content to be retrieved via a {@link #getContentAsByteArray() byte array}.
4242
*
43+
* <p>This class acts as an interceptor that only caches content as it is being
44+
* read but otherwise does not cause content to be read. That means if the request
45+
* content is not consumed, then the content is not cached, and cannot be
46+
* retrieved via {@link #getContentAsByteArray()}.
47+
*
4348
* <p>Used e.g. by {@link org.springframework.web.filter.AbstractRequestLoggingFilter}.
4449
* Note: As of Spring Framework 5.0, this wrapper is built on the Servlet 3.1 API.
4550
*
51+
*
4652
* @author Juergen Hoeller
4753
* @author Brian Clozel
4854
* @since 4.1.3
@@ -184,6 +190,10 @@ private void writeRequestParametersToCachedContent() {
184190
/**
185191
* Return the cached request content as a byte array.
186192
* <p>The returned array will never be larger than the content cache limit.
193+
* <p><strong>Note:</strong> The byte array returned from this method
194+
* reflects the amount of content that has has been read at the time when it
195+
* is called. If the application does not read the content, this method
196+
* returns an empty array.
187197
* @see #ContentCachingRequestWrapper(HttpServletRequest, int)
188198
*/
189199
public byte[] getContentAsByteArray() {

0 commit comments

Comments
 (0)