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 e29ba3e1aaea8..c4d3d5df48695 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 @@ protected void doDisconnect() throws GenericFileOperationFailedException { 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()); }