You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/07/14 14:21:20 UTC
(commons-io) 01/04: BoundedInputStream does not call handleIOException() on close() when the proxied stream throws an IOException
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
commit bc11cc03f231cd7e945d5e27835dbd51a1bf841d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jul 14 09:47:28 2024 -0400
BoundedInputStream does not call handleIOException() on close() when the
proxied stream throws an IOException
---
src/changes/changes.xml | 3 ++-
src/main/java/org/apache/commons/io/input/BoundedInputStream.java | 2 +-
.../java/org/apache/commons/io/input/BoundedInputStreamTest.java | 6 ++++++
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 14c59ec57..f645bcaf9 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -83,7 +83,8 @@ The <action> type attribute can be add,update,fix,remove.
<action dev="ggregory" type="fix" due-to="Gary Gregory">RandomAccessFileInputStream.read() should return -1 (EOF) after the stream is closed.</action>
<action dev="ggregory" type="fix" due-to="Gary Gregory">ReaderInputStream.available() should return 0 after the stream is closed.</action>
<action dev="ggregory" type="fix" due-to="Gary Gregory">ReaderInputStream.read() should return -1 (EOF) after the stream is closed.</action>
- <action dev="ggregory" type="fix" due-to="Gary Gregory">AutoCloseInputStream does not call handleIOException() on close().</action>
+ <action dev="ggregory" type="fix" due-to="Gary Gregory">AutoCloseInputStream does not call handleIOException() on close() when the proxied stream throws an IOException.</action>
+ <action dev="ggregory" type="fix" due-to="Gary Gregory">BoundedInputStream does not call handleIOException() on close() when the proxied stream throws an IOException.</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.0.</action>
diff --git a/src/main/java/org/apache/commons/io/input/BoundedInputStream.java b/src/main/java/org/apache/commons/io/input/BoundedInputStream.java
index 83431db3a..f3b07b718 100644
--- a/src/main/java/org/apache/commons/io/input/BoundedInputStream.java
+++ b/src/main/java/org/apache/commons/io/input/BoundedInputStream.java
@@ -340,7 +340,7 @@ public class BoundedInputStream extends ProxyInputStream {
@Override
public void close() throws IOException {
if (propagateClose) {
- in.close();
+ super.close();
}
}
diff --git a/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java b/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java
index b5617782a..d81802ff4 100644
--- a/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java
@@ -23,6 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -71,6 +72,11 @@ public class BoundedInputStreamTest {
assertThrows(IllegalStateException.class, () -> BoundedInputStream.builder().get());
}
+ @Test
+ public void testCloseHandleIOException() throws IOException {
+ ProxyInputStreamTest.testCloseHandleIOException(BoundedInputStream.builder());
+ }
+
@SuppressWarnings("deprecation")
@ParameterizedTest
@ValueSource(longs = { -100, -1, 0, 1, 2, 4, 8, 16, 32, 64 })