Repository: camel Updated Branches: refs/heads/master 18dec0331 -> 559bdb126
CAMEL-8075 Camel ftp should send a command to check if the connection is broken before pulling the files Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/559bdb12 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/559bdb12 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/559bdb12 Branch: refs/heads/master Commit: 559bdb1267690266a49b0ca2f216ce75458af763 Parents: 18dec03 Author: Willem Jiang <willem.ji...@gmail.com> Authored: Thu Apr 23 11:15:04 2015 +0800 Committer: Willem Jiang <willem.ji...@gmail.com> Committed: Thu Apr 23 11:15:04 2015 +0800 ---------------------------------------------------------------------- .../camel/component/file/remote/RemoteFileConsumer.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/559bdb12/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java ---------------------------------------------------------------------- diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java index 1bf501d..80576bf 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java @@ -185,7 +185,15 @@ public abstract class RemoteFileConsumer<T> extends GenericFileConsumer<T> { } protected void connectIfNecessary() throws IOException { - if (!loggedIn) { + // We need to send a noop first to check if the connection is still open + boolean isConnected = false; + try { + isConnected = getOperations().sendNoop(); + } catch (Exception ex) { + // here we just ignore the exception and try to reconnect + } + + if (!loggedIn || !isConnected) { if (log.isDebugEnabled()) { log.debug("Not connected/logged in, connecting to: {}", remoteServer()); }