Author: bago
Date: Fri May 19 07:58:12 2006
New Revision: 407813

URL: http://svn.apache.org/viewvc?rev=407813&view=rev
Log:
Backport remotedelivery fixes: ArrayIndexOutOfBounds and missing unlock 
(JAMES-489 and JAMES-504)

Modified:
    
james/server/branches/v2.3/src/java/org/apache/james/transport/mailets/RemoteDelivery.java

Modified: 
james/server/branches/v2.3/src/java/org/apache/james/transport/mailets/RemoteDelivery.java
URL: 
http://svn.apache.org/viewvc/james/server/branches/v2.3/src/java/org/apache/james/transport/mailets/RemoteDelivery.java?rev=407813&r1=407812&r2=407813&view=diff
==============================================================================
--- 
james/server/branches/v2.3/src/java/org/apache/james/transport/mailets/RemoteDelivery.java
 (original)
+++ 
james/server/branches/v2.3/src/java/org/apache/james/transport/mailets/RemoteDelivery.java
 Fri May 19 07:58:12 2006
@@ -155,6 +155,10 @@
             if (state.equals(Mail.ERROR)) {
                 //Test the time...
                 int retries = Integer.parseInt(errorMessage);
+                
+                // If the retries count is 0 we should try to send the mail 
now!
+                if (retries == 0) return true;
+                
                 long delay = getNextDelay (retries);
                 long timeToProcess = delay + lastUpdated;
 
@@ -1085,7 +1089,7 @@
 
         Session session = Session.getInstance(props, null);
         try {
-            while (!Thread.currentThread().interrupted() && !destroyed) {
+            while (!Thread.interrupted() && !destroyed) {
                 try {
                     Mail mail = (Mail)outgoing.accept(delayFilter);
                     String key = mail.getName();
@@ -1104,6 +1108,13 @@
                         } else {
                             //Something happened that will delay delivery.  
Store any updates
                             outgoing.store(mail);
+                            // This is an update, we have to unlock and notify 
or this mail
+                            // is kept locked by this thread
+                            outgoing.unlock(key);
+                            // We do not notify because we updated an already 
existing mail
+                            // and we are now free to handle more mails.
+                            // Furthermore this mail should not be processed 
now because we
+                            // have a retry time scheduling.
                         }
                         //Clear the object handle to make sure it recycles 
this object.
                         mail = null;
@@ -1122,7 +1133,7 @@
             }
         } finally {
             // Restore the thread state to non-interrupted.
-            Thread.currentThread().interrupted();
+            Thread.interrupted();
         }
     }
 
@@ -1172,7 +1183,7 @@
     private long getNextDelay (int retry_count) {
         if (retry_count > delayTimes.length) {
             return DEFAULT_DELAY_TIME;
-        }
+        } 
         return delayTimes[retry_count-1];
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to