Skip to content

Commit 43d72e2

Browse files
committed
Restored capacity check before trying output stream resize
Issue: SPR-13671
1 parent e707347 commit 43d72e2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ public PrintWriter getWriter() throws IOException {
123123

124124
@Override
125125
public void setContentLength(int len) {
126-
this.content.resize(len);
126+
if (len > this.content.size()) {
127+
this.content.resize(len);
128+
}
127129
this.contentLength = len;
128130
}
129131

@@ -134,13 +136,17 @@ public void setContentLengthLong(long len) {
134136
Integer.MAX_VALUE + "): " + len);
135137
}
136138
int lenInt = (int) len;
137-
this.content.resize(lenInt);
139+
if (lenInt > this.content.size()) {
140+
this.content.resize(lenInt);
141+
}
138142
this.contentLength = lenInt;
139143
}
140144

141145
@Override
142146
public void setBufferSize(int size) {
143-
this.content.resize(size);
147+
if (size > this.content.size()) {
148+
this.content.resize(size);
149+
}
144150
}
145151

146152
@Override

0 commit comments

Comments
 (0)