camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1441880 - in /camel/branches/camel-2.10.x: ./ components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
Date Sun, 03 Feb 2013 09:56:15 GMT
Author: davsclaus
Date: Sun Feb  3 09:56:15 2013
New Revision: 1441880

URL: http://svn.apache.org/viewvc?rev=1441880&view=rev
Log:
CAMEL-5459: Added option closeFolder to mail consumer to allow end users to control if folder
should be closed after poll or not. Thanks to Fabio Berchtold for the patch.

Modified:
    camel/branches/camel-2.10.x/   (props changed)
    camel/branches/camel-2.10.x/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
    camel/branches/camel-2.10.x/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1441879

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.10.x/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java?rev=1441880&r1=1441879&r2=1441880&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
(original)
+++ camel/branches/camel-2.10.x/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
Sun Feb  3 09:56:15 2013
@@ -62,6 +62,7 @@ public class MailConfiguration implement
     private boolean useInlineAttachments;
     private boolean ignoreUnsupportedCharset;
     private boolean disconnect;
+    private boolean closeFolder = true;
     private SSLContextParameters sslContextParameters;
 
     public MailConfiguration() {
@@ -468,7 +469,15 @@ public class MailConfiguration implement
     public void setDisconnect(boolean disconnect) {
         this.disconnect = disconnect;
     }
-    
+
+    public boolean isCloseFolder() {
+        return closeFolder;
+    }
+
+    public void setCloseFolder(boolean closeFolder) {
+        this.closeFolder = closeFolder;
+    }
+
     public SSLContextParameters getSslContextParameters() {
         return sslContextParameters;
     }

Modified: camel/branches/camel-2.10.x/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java?rev=1441880&r1=1441879&r2=1441880&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
(original)
+++ camel/branches/camel-2.10.x/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
Sun Feb  3 09:56:15 2013
@@ -119,25 +119,32 @@ public class MailConsumer extends Schedu
         } catch (Exception e) {
             handleException(e);
         } finally {
-            // need to ensure we release resources
-            try {
-                if (folder.isOpen()) {
-                    folder.close(true);
+            // need to ensure we release resources, but only if closeFolder or disconnect
= true
+            if (getEndpoint().getConfiguration().isCloseFolder() || getEndpoint().getConfiguration().isDisconnect())
{
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Close mailbox folder {} from {}", folder.getName(), getEndpoint().getConfiguration().getMailStoreLogInformation());
+                }
+                try {
+                    if (folder.isOpen()) {
+                        folder.close(true);
+                    }
+                } catch (Exception e) {
+                    // some mail servers will lock the folder so we ignore in this case (CAMEL-1263)
+                    LOG.debug("Could not close mailbox folder: " + folder.getName() + ".
This exception is ignored.", e);
                 }
-            } catch (Exception e) {
-                // some mail servers will lock the folder so we ignore in this case (CAMEL-1263)
-                LOG.debug("Could not close mailbox folder: " + folder.getName(), e);
             }
         }
 
         // should we disconnect, the header can override the configuration
         boolean disconnect = getEndpoint().getConfiguration().isDisconnect();
         if (disconnect) {
-            LOG.debug("Disconnecting from {}", getEndpoint().getConfiguration().getMailStoreLogInformation());
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Disconnecting from {}", getEndpoint().getConfiguration().getMailStoreLogInformation());
+            }
             try {
                 store.close();
             } catch (Exception e) {
-                LOG.debug("Could not disconnect from {}: " + getEndpoint().getConfiguration().getMailStoreLogInformation(),
e);
+                LOG.debug("Could not disconnect from {}: " + getEndpoint().getConfiguration().getMailStoreLogInformation()
+ ". This exception is ignored.", e);
             }
             store = null;
             folder = null;



Mime
View raw message