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 a62527a5d Rework FTPClientWrapper.disconnect() to remove any chance of 
a new connection being created on demand
a62527a5d is described below

commit a62527a5dac3cb3abcd6d4311eca4e83893ecae5
Author: Gary D. Gregory <garydgreg...@gmail.com>
AuthorDate: Tue Feb 25 16:48:52 2025 -0500

    Rework FTPClientWrapper.disconnect() to remove any chance of a new
    connection being created on demand
---
 .../commons/vfs2/provider/ftp/FTPClientWrapper.java   | 19 ++++++++++---------
 src/changes/changes.xml                               |  1 +
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FTPClientWrapper.java
 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FTPClientWrapper.java
index 2528a07de..c3f44f178 100644
--- 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FTPClientWrapper.java
+++ 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FTPClientWrapper.java
@@ -71,7 +71,6 @@ public class FTPClientWrapper implements FtpClient {
             // it should be better to really "abort" the transfer, but
             // currently I didn't manage to make it work - so lets "abort" the 
hard way.
             // return getFtpClient().abort();
-
             disconnect();
             return true;
         } catch (final IOException e) {
@@ -145,17 +144,19 @@ public class FTPClientWrapper implements FtpClient {
 
     @Override
     public void disconnect() throws IOException {
-        try {
-            getFtpClient().quit();
-        } catch (final IOException e) {
-            LOG.debug("I/O exception while trying to quit, probably it's a 
timed out connection, ignoring.", e);
-        } finally {
+        if (ftpClient != null) {
             try {
-                getFtpClient().disconnect();
+                ftpClient.quit();
             } catch (final IOException e) {
-                LOG.warn("I/O exception while trying to disconnect, probably 
it's a closed connection, ignoring.", e);
+                LOG.debug("I/O exception while trying to quit, connection 
likely timed out, ignoring.", e);
             } finally {
-                ftpClient = null;
+                try {
+                    getFtpClient().disconnect();
+                } catch (final IOException e) {
+                    LOG.warn("I/O exception while trying to disconnect, 
connection likely closed, ignoring.", e);
+                } finally {
+                    ftpClient = null;
+                }
             }
         }
     }
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index ccb1a06b3..7ccca1a98 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -47,6 +47,7 @@ The <action> type attribute can be add,update,fix,remove.
   <body>
     <release version="2.11.0" date="YYYY-MM-DD" description="This is a feature 
and maintenance release. Java 8 or later is required.">
       <!-- FIX -->
+      <action dev="ggregory" type="update" due-to="Gary Gregory">Rework 
FTPClientWrapper.disconnect() to remove any chance of a new connection being 
created on demand.</action>
       <!-- ADD -->
       <action dev="ggregory" type="update" due-to="Gary Gregory">Add 
org.apache.commons.vfs2.provider.ftp.FTPClientWrapper.sendOptions(String, 
String).</action>
       <action dev="ggregory" type="update" due-to="Gary Gregory">Add 
FtpFileSystemConfigBuilder.getControlEncodingCharset(FileSystemOptions) and 
deprecate getControlEncoding(FileSystemOptions).</action>

Reply via email to