camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [1/4] camel git commit: CAMEL-8075 Camel ftp should send a command to check if the connection is broken before pulling the files
Date Thu, 23 Apr 2015 06:31:12 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.14.x e53e97de0 -> 02b0fbd40
  refs/heads/camel-2.15.x 5a73ecf3b -> 24fc1a67b


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/5a03b104
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5a03b104
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5a03b104

Branch: refs/heads/camel-2.15.x
Commit: 5a03b1040a62c8d7cd33ef4f8210cb5d0c9723ee
Parents: 5a73ecf
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Thu Apr 23 11:15:04 2015 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Thu Apr 23 14:30:30 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/5a03b104/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());
             }


Mime
View raw message