This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git
The following commit(s) were added to refs/heads/master by this push: new efe9c63fe MarkShieldInputStream.read(*) should throw IOException when it is closed efe9c63fe is described below commit efe9c63fe046751972bbe519c46247094b6f39e9 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Wed Aug 7 15:07:36 2024 -0400 MarkShieldInputStream.read(*) should throw IOException when it is closed --- src/changes/changes.xml | 1 + .../org/apache/commons/io/input/MarkShieldInputStreamTest.java | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 99684ab39..ea96f6f71 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -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> diff --git a/src/test/java/org/apache/commons/io/input/MarkShieldInputStreamTest.java b/src/test/java/org/apache/commons/io/input/MarkShieldInputStreamTest.java index 12ff9e689..9f9ea5337 100644 --- a/src/test/java/org/apache/commons/io/input/MarkShieldInputStreamTest.java +++ b/src/test/java/org/apache/commons/io/input/MarkShieldInputStreamTest.java @@ -24,7 +24,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; 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; @@ -123,17 +122,15 @@ public class MarkShieldInputStreamTest { } } - @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