This is an automated email from the ASF dual-hosted git repository.

pkarwasz pushed a commit to branch fix/remove-exception-handler
in repository https://gitbox.apache.org/repos/asf/commons-io.git

commit 75e25284f35e9c8f7451d4dba5ba41f8ba09b064
Author: Piotr P. Karwasz <[email protected]>
AuthorDate: Fri Sep 5 15:20:12 2025 +0200

    chore: inline `ProxyInputStream.exceptionHandler` field
    
    The private, final field `exceptionHandler` was always set to 
`Erase::rethrow` and had no way to be changed (no setter provided). By inlining 
its single usage, `handleIOException` becomes simpler and its behavior is 
clearly fixed, with changes only possible through subclassing.
---
 src/changes/changes.xml                                       |  1 +
 .../java/org/apache/commons/io/input/ProxyInputStream.java    | 11 +----------
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index de92deabf..0b4ca4fea 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -50,6 +50,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="fix" dev="ggregory"                due-to="Gary 
Gregory">When testing on Java 21 and up, enable 
-XX:+EnableDynamicAgentLoading.</action>
       <action type="fix" dev="ggregory"                due-to="Gary 
Gregory">When testing on Java 24 and up, don't fail FileUtilsListFilesTest for 
a different behavior in the JRE.</action>
       <action type="fix" dev="ggregory"                due-to="Stanislav Fort, 
Gary Gregory">ValidatingObjectInputStream does not validate dynamic proxy 
interfaces.</action>
+      <action type="fix" dev="pkarwasz"                due-to="Piotr P. 
Karwasz">Inline constant ProxyInputStream.exceptionHandler field.</action>
       <!-- ADD -->
       <action dev="ggregory" type="add"                
due-to="strangelookingnerd, Gary Gregory">FileUtils#byteCountToDisplaySize() 
supports Zettabyte, Yottabyte, Ronnabyte and Quettabyte #763.</action>
       <action dev="ggregory" type="add"                
due-to="strangelookingnerd, Gary Gregory">Add 
org.apache.commons.io.FileUtils.ONE_RB #763.</action>
diff --git a/src/main/java/org/apache/commons/io/input/ProxyInputStream.java 
b/src/main/java/org/apache/commons/io/input/ProxyInputStream.java
index 6687d008d..b2e04c334 100644
--- a/src/main/java/org/apache/commons/io/input/ProxyInputStream.java
+++ b/src/main/java/org/apache/commons/io/input/ProxyInputStream.java
@@ -24,8 +24,6 @@
 
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.build.AbstractStreamBuilder;
-import org.apache.commons.io.function.Erase;
-import org.apache.commons.io.function.IOConsumer;
 import org.apache.commons.io.function.IOIntConsumer;
 
 /**
@@ -102,11 +100,6 @@ public B setAfterRead(final IOIntConsumer afterRead) {
      */
     private volatile boolean closed;
 
-    /**
-     * Handles exceptions.
-     */
-    private final IOConsumer<IOException> exceptionHandler;
-
     private final IOIntConsumer afterRead;
 
     /**
@@ -130,7 +123,6 @@ protected ProxyInputStream(final AbstractBuilder<?, ?> 
builder) throws IOExcepti
     public ProxyInputStream(final InputStream proxy) {
         // the delegate is stored in a protected superclass variable named 
'in'.
         super(proxy);
-        this.exceptionHandler = Erase::rethrow;
         this.afterRead = IOIntConsumer.NOOP;
     }
 
@@ -144,7 +136,6 @@ public ProxyInputStream(final InputStream proxy) {
     protected ProxyInputStream(final InputStream proxy, final 
AbstractBuilder<?, ?> builder) {
         // the delegate is stored in a protected superclass instance variable 
named 'in'.
         super(proxy);
-        this.exceptionHandler = Erase::rethrow;
         this.afterRead = builder.getAfterRead() != null ? 
builder.getAfterRead() : IOIntConsumer.NOOP;
     }
 
@@ -245,7 +236,7 @@ public void close() throws IOException {
      * @since 2.0
      */
     protected void handleIOException(final IOException e) throws IOException {
-        exceptionHandler.accept(e);
+        throw e;
     }
 
     /**

Reply via email to