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 2025/07/15 00:08:23 UTC

(commons-vfs) 03/04: Make sure org.apache.commons.vfs2.provider.http5.MonitoredHttpResponseContentInputStream.onClose() always closes its ClassicHttpResponse

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-vfs.git

commit 815450929adea118201fde3324fb6664147e4f8c
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Mon Jul 14 19:59:22 2025 -0400

    Make sure
    org.apache.commons.vfs2.provider.http5.MonitoredHttpResponseContentInputStream.onClose()
    always closes its ClassicHttpResponse
---
 .../http5/MonitoredHttpResponseContentInputStream.java      | 13 ++++++++-----
 src/changes/changes.xml                                     |  1 +
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/MonitoredHttpResponseContentInputStream.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/MonitoredHttpResponseContentInputStream.java
index e2186e481..efedfcd44 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/MonitoredHttpResponseContentInputStream.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/MonitoredHttpResponseContentInputStream.java
@@ -50,11 +50,14 @@ final class MonitoredHttpResponseContentInputStream extends MonitorInputStream {
 
     @Override
     protected void onClose() throws IOException {
-        // Replace the response's entity with a dummy entity in order to prevent
-        // exhausting all data (VFS-805)
-        httpResponse.setEntity(NullEntity.INSTANCE);
-        // Note that this also calls close on the dummy entity
-        httpResponse.close();
+        try {
+            // Replace the response's entity with a dummy entity in order to prevent
+            // exhausting all data (VFS-805)
+            httpResponse.setEntity(NullEntity.INSTANCE);
+            // Note that this also calls close on the dummy entity
+        } finally {
+            httpResponse.close();
+        }
     }
 
 }
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index b862d5525..084716a9f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -52,6 +52,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="fix" due-to="Anthony Goubard">Improve performance of encoding URIs #660.</action>
       <action dev="ggregory" type="fix" due-to="Anthony Goubard">Improved performance of UriParser#extractScheme #614.</action>
       <action dev="ggregory" type="fix" due-to="Andrey Turbanov, Gary Gregory">Fix Javadoc for ResourceFileSystemConfigBuilder #695.</action> 
+      <action dev="ggregory" type="fix" due-to="Gary Gregory">Make sure org.apache.commons.vfs2.provider.http5.MonitoredHttpResponseContentInputStream.onClose() always closes its ClassicHttpResponse.</action>
       <!-- ADD -->
       <action dev="ggregory" type="add" due-to="Gary Gregory">Add org.apache.commons.vfs2.provider.ftp.FTPClientWrapper.sendOptions(String, String).</action>
       <action dev="ggregory" type="add" due-to="Gary Gregory">Add FtpFileSystemConfigBuilder.getControlEncodingCharset(FileSystemOptions) and deprecate getControlEncoding(FileSystemOptions).</action>