Author: davsclaus
Date: Thu Jul 22 15:00:15 2010
New Revision: 966700

URL: http://svn.apache.org/viewvc?rev=966700&view=rev
Log:
CAMEL-2979: ftp consumer will only try to re-connect if maxReconnectOption 
allows it to do so.

Added:
    
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpNoReconnectAttemptUnknownHostTest.java
      - copied, changed from r966672, 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpReconnectAttemptUnknownHostTest.java
Modified:
    
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
    
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java

Modified: 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java?rev=966700&r1=966699&r2=966700&view=diff
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
 (original)
+++ 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
 Thu Jul 22 15:00:15 2010
@@ -44,7 +44,17 @@ public abstract class RemoteFileConsumer
     }
 
     protected boolean prePollCheck() throws Exception {
-        recoverableConnectIfNecessary();
+        try {
+            if (getEndpoint().getMaximumReconnectAttempts() > 0) {
+                // only use recoverable if we are allowed any re-connect 
attempts
+                recoverableConnectIfNecessary();
+            } else {
+                connectIfNecessary();
+            }
+        } catch (Exception e) {
+            loggedIn = false;
+        }
+
         if (!loggedIn) {
             String message = "Could not connect/login to: " + remoteServer() + 
". Will skip this poll.";
             log.warn(message);

Modified: 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java?rev=966700&r1=966699&r2=966700&view=diff
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
 (original)
+++ 
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
 Thu Jul 22 15:00:15 2010
@@ -97,7 +97,7 @@ public abstract class RemoteFileEndpoint
      * @throws Exception is thrown if endpoint is invalid configured for its 
mandatory options
      */
     protected void afterPropertiesSet() throws Exception {
-        RemoteFileConfiguration config = (RemoteFileConfiguration) 
getConfiguration();
+        RemoteFileConfiguration config = getConfiguration();
         ObjectHelper.notEmpty(config.getHost(), "host");
         ObjectHelper.notEmpty(config.getProtocol(), "protocol");
     }

Copied: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpNoReconnectAttemptUnknownHostTest.java
 (from r966672, 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpReconnectAttemptUnknownHostTest.java)
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpNoReconnectAttemptUnknownHostTest.java?p2=camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpNoReconnectAttemptUnknownHostTest.java&p1=camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpReconnectAttemptUnknownHostTest.java&r1=966672&r2=966700&rev=966700&view=diff
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpReconnectAttemptUnknownHostTest.java
 (original)
+++ 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpNoReconnectAttemptUnknownHostTest.java
 Thu Jul 22 15:00:15 2010
@@ -23,10 +23,10 @@ import org.junit.Test;
 /**
  * @version $Revision$
  */
-public class FtpReconnectAttemptUnknownHostTest extends FtpServerTestSupport {
+public class FtpNoReconnectAttemptUnknownHostTest extends FtpServerTestSupport 
{
 
     private String getFtpUrl() {
-        return "ftp://ad...@doesnotexisthost:"; + getPort() + 
"/reconnect?password=admin";
+        return "ftp://ad...@doesnotexisthost:"; + getPort() + 
"/reconnect?maximumReconnectAttempts=0&password=admin";
     }
 
     @Test


Reply via email to