JAMES-1877 Make mail lifeCycle readable in DeliveryRunnable
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/cb0cb77c Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/cb0cb77c Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/cb0cb77c Branch: refs/heads/master Commit: cb0cb77cdcbd605b8e09d289a2b78f7eff1fcb28 Parents: 2e60b2d Author: Benoit Tellier <btell...@linagora.com> Authored: Thu Dec 1 16:12:39 2016 +0700 Committer: Benoit Tellier <btell...@linagora.com> Committed: Tue Jan 10 15:12:49 2017 +0700 ---------------------------------------------------------------------- .../mailets/remoteDelivery/DeliveryRunnable.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/cb0cb77c/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/DeliveryRunnable.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/DeliveryRunnable.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/DeliveryRunnable.java index 75fb3e2..b8be45d 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/DeliveryRunnable.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/DeliveryRunnable.java @@ -101,10 +101,8 @@ public class DeliveryRunnable implements Runnable { if (configuration.isDebug()) { logger.debug(Thread.currentThread().getName() + " will process mail " + mail.getName()); } - attemptDelivery(session, mail); - - // Clear the object handle to make sure it recycles this object. + LifecycleUtil.dispose(mail); mail = null; queueItem.done(true); } catch (Exception e) { @@ -131,10 +129,7 @@ public class DeliveryRunnable implements Runnable { } private void attemptDelivery(Session session, Mail mail) throws MailQueue.MailQueueException { - if (deliver(mail, session)) { - // Message was successfully delivered/fully failed... delete it - LifecycleUtil.dispose(mail); - } else { + if (!deliver(mail, session)) { // Something happened that will delay delivery. Store it back in the retry repository. long delay = getNextDelay(DeliveryRetriesHelper.retrieveRetries(mail)); @@ -143,7 +138,6 @@ public class DeliveryRunnable implements Runnable { mail.setAttribute(MailPrioritySupport.MAIL_PRIORITY, MailPrioritySupport.LOW_PRIORITY); } queue.enQueue(mail, delay, TimeUnit.MILLISECONDS); - LifecycleUtil.dispose(mail); } } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org