File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
main/java/org/springframework/mock/web
test/java/org/springframework/mock/web Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -100,9 +100,6 @@ public class MockHttpServletRequest implements HttpServletRequest {
100
100
101
101
private static final TimeZone GMT = TimeZone .getTimeZone ("GMT" );
102
102
103
- private static final BufferedReader EMPTY_BUFFERED_READER =
104
- new BufferedReader (new StringReader ("" ));
105
-
106
103
/**
107
104
* Date formats as specified in the HTTP RFC.
108
105
* @see <a href="https://tools.ietf.org/html/rfc7231#section-7.1.1.1">Section 7.1.1.1 of RFC 7231</a>
@@ -738,7 +735,7 @@ else if (this.inputStream != null) {
738
735
this .reader = new BufferedReader (sourceReader );
739
736
}
740
737
else {
741
- this .reader = EMPTY_BUFFERED_READER ;
738
+ this .reader = new BufferedReader ( new StringReader ( "" )) ;
742
739
}
743
740
return this .reader ;
744
741
}
Original file line number Diff line number Diff line change @@ -93,6 +93,17 @@ void readEmptyInputStreamWorksAcrossRequests() throws IOException {
93
93
secondRequest .getInputStream ().close ();
94
94
}
95
95
96
+ @ Test // gh-32820
97
+ void readEmptyReaderWorksAcrossRequests () throws IOException {
98
+ MockHttpServletRequest firstRequest = new MockHttpServletRequest ();
99
+ firstRequest .getReader ().read (new char [256 ]);
100
+ firstRequest .getReader ().close ();
101
+
102
+ MockHttpServletRequest secondRequest = new MockHttpServletRequest ();
103
+ secondRequest .getReader ().read (new char [256 ]);
104
+ secondRequest .getReader ().close ();
105
+ }
106
+
96
107
@ Test
97
108
void setContentAndGetReader () throws IOException {
98
109
byte [] bytes = "body" .getBytes (Charset .defaultCharset ());
You can’t perform that action at this time.
0 commit comments