You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/08/25 11:40:29 UTC
[camel] branch camel-3.4.x updated: CAMEL-15460: FTP reconnect to
handle pending command and noop result (#4125)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-3.4.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.4.x by this push:
new 0868e7e CAMEL-15460: FTP reconnect to handle pending command and noop result (#4125)
0868e7e is described below
commit 0868e7e3262c189fc6740e5773c0e48836d6d9dc
Author: Lukas Holthof <68...@users.noreply.github.com>
AuthorDate: Tue Aug 25 13:39:27 2020 +0200
CAMEL-15460: FTP reconnect to handle pending command and noop result (#4125)
---
.../camel/component/file/remote/FtpOperations.java | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 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 0a83906..d549316 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
@@ -344,7 +344,6 @@ public class FtpOperations implements RemoteFileOperations<FTPFile> {
public boolean renameFile(String from, String to) throws GenericFileOperationFailedException {
log.debug("Renaming file: {} to: {}", from, to);
try {
- reconnectIfNecessary(null);
return client.rename(from, to);
} catch (IOException e) {
throw new GenericFileOperationFailedException(client.getReplyCode(), client.getReplyString(), e.getMessage(), e);
@@ -990,16 +989,18 @@ public class FtpOperations implements RemoteFileOperations<FTPFile> {
}
private void reconnectIfNecessary(Exchange exchange) throws GenericFileOperationFailedException {
- if (isConnected()) {
- log.trace("sendNoOp to check if connection should be reconnected");
- try {
- client.sendNoOp();
- } catch (IOException e) {
- log.trace("NoOp to server failed, try to reconnect");
- connect(endpoint.getConfiguration(), exchange);
+ boolean reconnectRequired = false;
+ try {
+ client.completePendingCommand();
+ if (!isConnected() || !sendNoop()) {
+ reconnectRequired = true;
}
- } else {
- log.trace("Client is not connected, try to reconnect");
+ } catch (IOException | GenericFileOperationFailedException e) {
+ // Ignore Exception and reconnect the client
+ reconnectRequired = true;
+ }
+ if (reconnectRequired) {
+ log.trace("Client is not connected anymore, try to reconnect");
connect(endpoint.getConfiguration(), exchange);
}
}