@@ -133,6 +133,31 @@ public void testReadAfterClose(final int len) throws Exception {
133133 }
134134 }
135135
136+ @ ParameterizedTest
137+ @ MethodSource (AbstractInputStreamTest .ARRAY_LENGTHS_NAME )
138+ public void testReadByteArrayAfterClose (final int len ) throws Exception {
139+ try (MarkTestableInputStream in = new MarkTestableInputStream (new NullInputStream (len , false , false ));
140+ final MarkShieldInputStream msis = new MarkShieldInputStream (in )) {
141+ assertEquals (len , in .available ());
142+ in .close ();
143+ assertEquals (0 , in .read (new byte [0 ]));
144+ assertThrows (IOException .class , () -> in .read (new byte [2 ]));
145+ }
146+ }
147+
148+ @ ParameterizedTest
149+ @ MethodSource (AbstractInputStreamTest .ARRAY_LENGTHS_NAME )
150+ public void testReadByteArrayIntIntAfterClose (final int len ) throws Exception {
151+ try (MarkTestableInputStream in = new MarkTestableInputStream (new NullInputStream (len , false , false ));
152+ final MarkShieldInputStream msis = new MarkShieldInputStream (in )) {
153+ assertEquals (len , in .available ());
154+ in .close ();
155+ assertEquals (0 , in .read (new byte [0 ], 0 , 1 ));
156+ assertEquals (0 , in .read (new byte [1 ], 0 , 0 ));
157+ assertThrows (IOException .class , () -> in .read (new byte [2 ], 0 , 1 ));
158+ }
159+ }
160+
136161 @ Test
137162 public void testResetThrowsExceptionWhenUnderlyingDoesNotSupport () throws IOException {
138163 // test wrapping an underlying stream which does NOT support marking
0 commit comments