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

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 7b752c8e6d1 (chores) camel-ftp: prevent disconnect from suppressing 
exception
7b752c8e6d1 is described below

commit 7b752c8e6d16ccd5a22ffaf7c9c7d2e24b20c7ce
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Tue Jan 10 10:11:41 2023 +0100

    (chores) camel-ftp: prevent disconnect from suppressing exception
---
 .../apache/camel/component/file/remote/FtpOperations.java  | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
index e29ba3e1aae..c4d3d5df486 100644
--- 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
+++ 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
@@ -302,17 +302,21 @@ public class FtpOperations implements 
RemoteFileOperations<FTPFile> {
         try {
             log.trace("Client logout");
             client.logout();
+            client.disconnect();
         } catch (IOException e) {
-            throw new 
GenericFileOperationFailedException(client.getReplyCode(), 
client.getReplyString(), e.getMessage(), e);
-        } finally {
+            GenericFileOperationFailedException gfo = new 
GenericFileOperationFailedException(
+                    client.getReplyCode(), client.getReplyString(), 
e.getMessage(), e);
             try {
                 log.trace("Client disconnect");
                 client.disconnect();
-            } catch (IOException e) {
-                throw new GenericFileOperationFailedException(
-                        client.getReplyCode(), client.getReplyString(), 
e.getMessage(), e);
+            } catch (IOException ed) {
+                log.warn("Failed to disconnect: {}", e.getMessage(), e);
+                gfo.addSuppressed(ed);
             }
+
+            throw gfo;
         }
+
         
clientActivityListener.onDisconnected(endpoint.getConfiguration().remoteServerInformation());
     }
 

Reply via email to