Skip to content

Commit

Permalink
MarkShieldInputStream.read(*) should throw IOException when it is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Aug 7, 2024
1 parent bdd804d commit efe9c63
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ The <action> type attribute can be add,update,fix,remove.
<action dev="ggregory" type="fix" due-to="Gary Gregory">NullInputStream.read(*) should throw IOException when it is closed.</action>
<action dev="ggregory" type="fix" due-to="Gary Gregory">NullInputStream.read(byte[]) should return 0 when the input byte array in length 0.</action>
<action dev="ggregory" type="fix" due-to="Gary Gregory">NullInputStream.read(byte[], int, int) should return 0 when the input byte array in length 0 or requested length is 0.</action>
<action dev="ggregory" type="fix" due-to="Gary Gregory">MarkShieldInputStream.read(*) should throw IOException when it is closed.</action>
<!-- UPDATE -->
<action dev="ggregory" type="update" due-to="Dependabot">Bump tests commons.bytebuddy.version from 1.14.13 to 1.14.18 #615, #621, #631, #635, #642.</action>
<action dev="ggregory" type="update" due-to="Dependabot">Bump tests commons-codec:commons-codec from 1.16.1 to 1.17.1 #644.</action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.io.IOException;
import java.io.InputStream;

import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
Expand Down Expand Up @@ -123,17 +122,15 @@ public void testMarkSupportedIsFalseWhenUnderlyingTrue() throws IOException {
}
}

@SuppressWarnings("resource")
@ParameterizedTest
@MethodSource(AbstractInputStreamTest.ARRAY_LENGTHS_NAME)
public void testReadAfterClose(final int len) throws Exception {
final InputStream shadow;
try (MarkTestableInputStream in = new MarkTestableInputStream(new NullInputStream(len, false, false));
final MarkShieldInputStream msis = new MarkShieldInputStream(in)) {
assertEquals(len, in.available());
shadow = in;
in.close();
assertThrows(IOException.class, in::read);
}
assertEquals(IOUtils.EOF, shadow.read());
}

@Test
Expand Down

0 comments on commit efe9c63

Please sign in to comment.