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 2019/02/01 13:32:18 UTC

[commons-vfs] branch master updated: [VFS-689] org.apache.commons.vfs2.provider.http.HttpFileObject.getHeadMethod() does not release connection when an exception is thrown.

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


The following commit(s) were added to refs/heads/master by this push:
     new a8f9164  [VFS-689] org.apache.commons.vfs2.provider.http.HttpFileObject.getHeadMethod() does not release connection when an exception is thrown.
a8f9164 is described below

commit a8f9164b85ab0145725713b6018863d338ff6230
Author: Gary Gregory <gg...@rocketsoftware.com>
AuthorDate: Fri Feb 1 08:32:17 2019 -0500

    [VFS-689]
    org.apache.commons.vfs2.provider.http.HttpFileObject.getHeadMethod()
    does not release connection when an exception is thrown.
---
 .../org/apache/commons/vfs2/provider/http/HttpFileObject.java | 11 +++++++----
 src/changes/changes.xml                                       |  3 +++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileObject.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileObject.java
index 1a73e14..9467dc8 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileObject.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileObject.java
@@ -201,10 +201,13 @@ public class HttpFileObject<FS extends HttpFileSystem> extends AbstractFileObjec
             return method;
         }
         method = new HeadMethod();
-        setupMethod(method);
-        final HttpClient client = getAbstractFileSystem().getClient();
-        client.executeMethod(method);
-        method.releaseConnection();
+        try {
+            setupMethod(method);
+            final HttpClient client = getAbstractFileSystem().getClient();
+            client.executeMethod(method);
+        } finally {
+            method.releaseConnection();
+        }
         return method;
     }
 
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 7710c3d..70340aa 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -137,6 +137,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action issue="VFS-360" dev="ggregory" type="add" due-to="Woonsan Ko">
         Add HTTP provider based on HttpComponents HttpClient 4.
       </action>
+      <action issue="VFS-689" dev="ggregory" type="add" due-to="Gary Gregory">
+        org.apache.commons.vfs2.provider.http.HttpFileObject.getHeadMethod() does not release connection when an exception is thrown.
+      </action>
     </release>
     <release version="2.2" date="2017-10-06" description="New features and bug fix release.">
       <action issue="VFS-642" dev="pschumacher" type="update" due-to="ilangoldfeld">