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 2009/03/30 13:58:02 UTC

svn commit: r759931 - /camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java

Author: davsclaus
Date: Mon Mar 30 11:58:02 2009
New Revision: 759931

URL: http://svn.apache.org/viewvc?rev=759931&view=rev
Log:
MR-157: Better re connect if not connected to mail store, eg catching exception that some mail server throws despite the API should just return a boolean.

Modified:
    camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java

Modified: camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java?rev=759931&r1=759930&r2=759931&view=diff
==============================================================================
--- camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java (original)
+++ camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java Mon Mar 30 11:58:02 2009
@@ -125,11 +125,22 @@
     protected void ensureIsConnected() throws MessagingException {
         MailConfiguration config = endpoint.getConfiguration();
 
-        if (store == null || !store.isConnected()) {
-            store = sender.getSession().getStore(config.getProtocol());
+        boolean connected = false;
+        try {
+            if (store != null && store.isConnected()) {
+                connected = true;
+            }
+        } catch (Exception e) {
+            LOG.debug("Exception while testing for is connected to MailStore: "
+                    + endpoint.getConfiguration().getMailStoreLogInformation()
+                    + ". Caused by: " + e.getMessage(), e);
+        }
+
+        if (!connected) {
             if (LOG.isDebugEnabled()) {
-                LOG.debug("Connecting to MailStore " + endpoint.getConfiguration().getMailStoreLogInformation());
+                LOG.debug("Connecting to MailStore: " + endpoint.getConfiguration().getMailStoreLogInformation());
             }
+            store = sender.getSession().getStore(config.getProtocol());
             store.connect(config.getHost(), config.getPort(), config.getUsername(), config.getPassword());
         }