File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
core/sdk-core/src/test/java/software/amazon/awssdk/core/internal/io Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -249,6 +249,27 @@ void readByte_readExactLength_doesNotThrow() throws IOException {
249249 assertThat (total ).isEqualTo (delegateLength );
250250 }
251251
252+ @ Test
253+ void readBytePartialThenMark_doesNotResetContentLength () throws IOException {
254+ int delegateLength = 16 ;
255+ int expectedContentLength = delegateLength + 1 ;
256+ ByteArrayInputStream delegate = new ByteArrayInputStream (new byte [delegateLength ]);
257+
258+ SdkLengthAwareInputStream is = new SdkLengthAwareInputStream (delegate , expectedContentLength );
259+ is .read (); // read one byte
260+ is .mark (1024 );
261+ // read another byte and reset, the length should not be reset based on the byte that was already read
262+ is .read ();
263+ is .reset ();
264+ assertThatThrownBy (() -> {
265+ int read ;
266+ while ((read = is .read ()) != -1 ) {
267+ }
268+ })
269+ .isInstanceOf (IllegalStateException .class )
270+ .hasMessageContaining ("The request content has fewer bytes than the specified content-length: " + expectedContentLength );
271+ }
272+
252273 @ Test
253274 void readByte_delegateLongerThanRequired_truncated () throws IOException {
254275 int delegateLength = 32 ;
You can’t perform that action at this time.
0 commit comments