You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by rd...@apache.org on 2008/08/03 23:21:47 UTC

svn commit: r682219 - in /james/server/trunk: core-library/src/main/java/org/apache/james/core/ experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ experimental-seda-imap-function/src/test/java/org/apache/james/test/...

Author: rdonkin
Date: Sun Aug  3 14:21:45 2008
New Revision: 682219

URL: http://svn.apache.org/viewvc?rev=682219&view=rev
Log:
Concurrency tests for IMAP

Added:
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/Concurrent.todo.txt
      - copied unchanged from r682165, james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/concurrent/Concurrent.todo.txt
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentDeleteSelected.test
      - copied, changed from r682165, james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/concurrent/DeleteSelected.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentExpungeResponse.test
      - copied unchanged from r682165, james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/concurrent/ExpungeResponse.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentFetchResponse.test
      - copied, changed from r682165, james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/concurrent/FetchResponse.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentRenameSelected.test
      - copied, changed from r682165, james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/concurrent/RenameSelected.test
Removed:
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/concurrent/Concurrent.todo.txt
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/concurrent/DeleteSelected.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/concurrent/ExpungeResponse.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/concurrent/FetchResponse.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/concurrent/RenameSelected.test
Modified:
    james/server/trunk/core-library/src/main/java/org/apache/james/core/MailImpl.java
    james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapRequestHandler.java
    james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestConcurrentSessions.java
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentExistsResponse.test
    james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/process/SelectedImapMailbox.java
    james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/base/SelectedMailboxSessionImpl.java
    james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/CreateProcessor.java
    james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/DeleteProcessor.java
    james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/commands/DeleteCommand.java
    james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/MailboxListener.java
    james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/impl/MailboxEventDispatcher.java
    james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/manager/MailboxManager.java
    james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/util/MailboxEventAnalyser.java
    james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/util/UidChangeTracker.java
    james/server/trunk/mailbox-library/src/test/java/org/apache/james/mailboxmanager/util/MailboxEventAnalyserTest.java
    james/server/trunk/phoenix-deployment/src/test/org/apache/james/experimental/imapserver/ExperimentalHostSystem.java
    james/server/trunk/phoenix-deployment/src/test/org/apache/james/mailboxmanager/torque/TorqueMailboxManagerTest.java
    james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java
    james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java

Modified: james/server/trunk/core-library/src/main/java/org/apache/james/core/MailImpl.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-library/src/main/java/org/apache/james/core/MailImpl.java?rev=682219&r1=682218&r2=682219&view=diff
==============================================================================
--- james/server/trunk/core-library/src/main/java/org/apache/james/core/MailImpl.java (original)
+++ james/server/trunk/core-library/src/main/java/org/apache/james/core/MailImpl.java Sun Aug  3 14:21:45 2008
@@ -28,6 +28,7 @@
 import org.apache.mailet.RFC2822Headers;
 
 import javax.mail.MessagingException;
+import javax.mail.SendFailedException;
 import javax.mail.internet.InternetAddress;
 import javax.mail.internet.MimeMessage;
 import javax.mail.internet.ParseException;
@@ -158,16 +159,19 @@
         setRemoteAddr(mail.getRemoteAddr());
         setLastUpdated(mail.getLastUpdated());
         try {
-            if (mail instanceof MailImpl) {
-                setAttributesRaw((HashMap) cloneSerializableObject(((MailImpl) mail).getAttributesRaw()));
-            } else {
-                HashMap attribs = new HashMap();
-                for (Iterator i = mail.getAttributeNames(); i.hasNext(); ) {
-                    String hashKey = (String) i.next();
-                    attribs.put(hashKey,cloneSerializableObject(mail.getAttribute(hashKey)));
+            HashMap attribs = new HashMap();
+            for (Iterator i = mail.getAttributeNames(); i.hasNext(); ) {
+                String hashKey = (String) i.next();
+                final Serializable attribute = mail.getAttribute(hashKey);
+                if (attribute instanceof SendFailedException) {
+                    SendFailedException ex = (SendFailedException) attribute;
+                    Throwable t = ex.getNextException();
+                    debug(t); 
                 }
-                setAttributesRaw(attribs);
+                final Object cloneSerializableObject = cloneSerializableObject(attribute);
+                attribs.put(hashKey,cloneSerializableObject);
             }
+            setAttributesRaw(attribs);
         } catch (IOException e) {
             // should never happen for in memory streams
             setAttributesRaw(new HashMap());
@@ -176,6 +180,28 @@
             setAttributesRaw(new HashMap());
         }
     }
+    private void debug(Throwable t) {
+        if (t == null) {
+            System.err.println("[END]");
+        } else {
+            System.err.println("NEXT@" + System.identityHashCode(t)  + t );
+            if (t instanceof MessagingException) {
+                MessagingException e = (MessagingException) t;
+                System.err.println("NEXT@" + System.identityHashCode(e)  + e );
+                t = e.getNextException();
+                if (t == null) {
+                    t = e.getCause();
+                }
+                debug(t);
+            } else {
+                System.err.println("NEXT@" + System.identityHashCode(t)  + t );
+                Throwable next = t.getCause();
+                if (next != t) {
+                    debug(next);
+                }
+            }
+        }
+    }
 
     /**
      * A constructor that creates a MailImpl with the specified name,
@@ -608,7 +634,7 @@
      * @throws IOException
      * @throws ClassNotFoundException
      */
-    private static Object cloneSerializableObject(Object o) throws IOException, ClassNotFoundException {
+    public static Object cloneSerializableObject(Object o) throws IOException, ClassNotFoundException {
         ByteArrayOutputStream b = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream(b);
         out.writeObject(o);

Modified: james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapRequestHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapRequestHandler.java?rev=682219&r1=682218&r2=682219&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapRequestHandler.java (original)
+++ james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapRequestHandler.java Sun Aug  3 14:21:45 2008
@@ -30,6 +30,7 @@
 import org.apache.james.api.imap.message.response.ImapResponseMessage;
 import org.apache.james.api.imap.process.ImapProcessor;
 import org.apache.james.api.imap.process.ImapSession;
+import org.apache.james.api.imap.process.SelectedImapMailbox;
 import org.apache.james.api.imap.process.ImapProcessor.Responder;
 import org.apache.james.experimental.imapserver.encode.writer.OutputStreamImapResponseWriter;
 import org.apache.james.imapserver.codec.ProtocolException;
@@ -47,6 +48,10 @@
     private static final byte[] ABANDON_SIGNOFF = {'*',' ', 'B', 'Y', 'E', ' ', 
         'A','b','a','n','d','o','n','e','d','\r', '\n'};
     
+    private static final byte[] MAILBOX_DELETED_SIGNOFF = {'*',' ','B','Y','E',' ',
+        'S','e','l','e','c','t','e','d',' ','m','a','i','l','b','o','x',' ','h','a',
+        's',' ','b','e','e','n',' ','d','e','l','e','t','e','d','\r','\n'};
+    
     private final ImapDecoder decoder;
     private final ImapProcessor processor;
     private final ImapEncoder encoder;
@@ -80,47 +85,72 @@
                                   OutputStream output,
                                   ImapSession session )
     {
-        ImapRequestLineReader request = new ImapRequestLineReader( input, output );
-        setupLogger(request);
-        
-        final Logger logger = getLogger();
-        try {
-            request.nextChar();
-        }
-        catch ( ProtocolException e ) {
-            logger.debug("Unexpected end of line. Cannot handle request: ", e);
-            return false;
-        }
-
-        ImapResponseComposerImpl response = new ImapResponseComposerImpl( new OutputStreamImapResponseWriter( output ));
-        response.enableLogging(logger); 
-
         final boolean result;
-        if (doProcessRequest( request, response, session )) {
-    
+        if (isSelectedMailboxDeleted(session)) {
+            writeSignoff(output);
+            result = false;
+        } else {
+            ImapRequestLineReader request = new ImapRequestLineReader( input, output );
+            setupLogger(request);
+            
+            final Logger logger = getLogger();
             try {
-                // Consume the rest of the line, throwing away any extras. This allows us
-                // to clean up after a protocol error.
-                request.consumeLine();
-            } catch (ProtocolException e) {
-                // Cannot clean up. No recovery is therefore possible.
-                // Abandon connection.
-                if (logger.isInfoEnabled()) {
-                    logger.info("Fault during clean up: " + e.getMessage());
+                request.nextChar();
+            }
+            catch ( ProtocolException e ) {
+                logger.debug("Unexpected end of line. Cannot handle request: ", e);
+                return false;
+            }
+    
+            ImapResponseComposerImpl response = new ImapResponseComposerImpl( new OutputStreamImapResponseWriter( output ));
+            response.enableLogging(logger); 
+    
+            if (doProcessRequest( request, response, session )) {
+        
+                try {
+                    // Consume the rest of the line, throwing away any extras. This allows us
+                    // to clean up after a protocol error.
+                    request.consumeLine();
+                } catch (ProtocolException e) {
+                    // Cannot clean up. No recovery is therefore possible.
+                    // Abandon connection.
+                    if (logger.isInfoEnabled()) {
+                        logger.info("Fault during clean up: " + e.getMessage());
+                    }
+                    logger.debug("Abandoning after fault in clean up", e);
+                    session.logout();
+                    abandon(output);
                 }
-                logger.debug("Abandoning after fault in clean up", e);
-                session.logout();
+        
+                result = !(ImapSessionState.LOGOUT == session.getState());
+            } else {
+                result = false;
                 abandon(output);
             }
-    
-            result = !(ImapSessionState.LOGOUT == session.getState());
-        } else {
-            result = false;
-            abandon(output);
         }
         return result;
     }
 
+    private void writeSignoff(OutputStream output) {
+        try {
+            output.write(MAILBOX_DELETED_SIGNOFF);
+        } catch (IOException e) {
+            getLogger().warn("Failed to write signoff");
+            getLogger().debug("Failed to write signoff:", e);
+        }
+    }
+
+    private boolean isSelectedMailboxDeleted(ImapSession session) {
+        final boolean selectedMailboxIsDeleted;
+        final SelectedImapMailbox mailbox = session.getSelected();
+        if (mailbox != null) {
+            selectedMailboxIsDeleted = mailbox.isDeletedByOtherSession();
+        } else {
+            selectedMailboxIsDeleted = false;
+        }
+        return selectedMailboxIsDeleted;
+    }
+
     private void abandon(OutputStream out) {
         try {
             out.write(ABANDON_SIGNOFF);

Modified: james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestConcurrentSessions.java
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestConcurrentSessions.java?rev=682219&r1=682218&r2=682219&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestConcurrentSessions.java (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestConcurrentSessions.java Sun Aug  3 14:21:45 2008
@@ -21,13 +21,57 @@
 
 import java.util.Locale;
 
-public abstract class AbstractTestConcurrentSessions extends AbstractSimpleScriptedTestProtocol {
+public abstract class AbstractTestConcurrentSessions extends AbstractTestForAuthenticatedState {
 
     public AbstractTestConcurrentSessions(HostSystem system) {
         super(system);
     }
 
-    public void testFetchEnvelopeUS() throws Exception {
-        //scriptTest("ConcurrentExistsResponse", Locale.US);
+    public void testConcurrentExistsResponseUS() throws Exception {
+        scriptTest("ConcurrentExistsResponse", Locale.US);
+    }
+    
+    public void testConcurrentDeleteSelectedUS() throws Exception {
+        scriptTest("ConcurrentDeleteSelected", Locale.US);
+    }
+    
+    public void testConcurrentFetchResponseUS() throws Exception {
+        scriptTest("ConcurrentFetchResponse", Locale.US);
+    }
+    
+    public void testConcurrentRenameSelectedUS() throws Exception {
+        scriptTest("ConcurrentRenameSelected", Locale.US);
+    }
+   
+    public void testConcurrentExistsResponseKOREA() throws Exception {
+        scriptTest("ConcurrentExistsResponse", Locale.KOREA);
+    }
+    
+    public void testConcurrentDeleteSelectedKOREA() throws Exception {
+        scriptTest("ConcurrentDeleteSelected", Locale.KOREA);
+    }
+    
+    public void testConcurrentFetchResponseKOREA() throws Exception {
+        scriptTest("ConcurrentFetchResponse", Locale.KOREA);
+    }
+    
+    public void testConcurrentRenameSelectedKOREA() throws Exception {
+        scriptTest("ConcurrentRenameSelected", Locale.KOREA);
+    }
+    
+    public void testConcurrentExistsResponseITALY() throws Exception {
+        scriptTest("ConcurrentExistsResponse", Locale.ITALY);
+    }
+    
+    public void testConcurrentDeleteSelectedITALY() throws Exception {
+        scriptTest("ConcurrentDeleteSelected", Locale.ITALY);
+    }
+    
+    public void testConcurrentFetchResponseITALY() throws Exception {
+        scriptTest("ConcurrentFetchResponse", Locale.ITALY);
+    }
+    
+    public void testConcurrentRenameSelectedITALY() throws Exception {
+        scriptTest("ConcurrentRenameSelected", Locale.ITALY);
     }
 }

Copied: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentDeleteSelected.test (from r682165, james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/concurrent/DeleteSelected.test)
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentDeleteSelected.test?p2=james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentDeleteSelected.test&p1=james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/concurrent/DeleteSelected.test&r1=682165&r2=682219&rev=682219&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/concurrent/DeleteSelected.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentDeleteSelected.test Sun Aug  3 14:21:45 2008
@@ -24,7 +24,7 @@
 
 SESSION: 1
 C: 1a CREATE deleteconcurrent
-S: 1a OK CREATE completed
+S: 1a OK CREATE completed.
 
 C: 1b APPEND deleteconcurrent (\Deleted) {254+}
 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
@@ -37,23 +37,24 @@
 C:
 C: Test 03
 C:
-S: 1b OK APPEND completed
+S: 1b OK APPEND completed.
 
 C: 1c SELECT deleteconcurrent
 S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
 S: \* 1 EXISTS
 S: \* 1 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
+S: \* OK \[UNSEEN 1\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
-S: 1c OK \[READ-WRITE\] SELECT completed
+S: 1c OK \[READ-WRITE\] SELECT completed.
 
 
 # Client #1 has mailbox "deleteconcurrent" selected. Client #2 DELETEs the mailbox.
 SESSION: 2
 C: 2a DELETE deleteconcurrent
-S: 2a OK DELETE completed
+S: 2a OK DELETE completed.
 
 # Forced disconnect of selected sessions
 SESSION: 1
-S: \* BYE Mailbox deleteconcurrent has been deleted
+C: 1A NOOP
+S: \* BYE Selected mailbox has been deleted

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentExistsResponse.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentExistsResponse.test?rev=682219&r1=682218&r2=682219&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentExistsResponse.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentExistsResponse.test Sun Aug  3 14:21:45 2008
@@ -23,8 +23,8 @@
 S: 1a OK CREATE completed.
 
 C: 1b STATUS existsresponse (MESSAGES)
-S: \* STATUS existsresponse \(MESSAGES 0\)
-S: 1b OK STATUS completed
+S: \* STATUS \"existsresponse\" \(MESSAGES 0\)
+S: 1b OK STATUS completed.
 
 SESSION: 2
 C: 2a SELECT existsresponse
@@ -32,9 +32,8 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
-S: 2a OK \[READ-WRITE\] SELECT completed
+S: 2a OK \[READ-WRITE\] SELECT completed.
 
 SESSION: 3
 C: 3a SELECT existsresponse
@@ -42,9 +41,8 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
-S: 3a OK \[READ-WRITE\] SELECT completed
+S: 3a OK \[READ-WRITE\] SELECT completed.
 
 SESSION: 4
 C: 4a SELECT existsresponse
@@ -52,9 +50,8 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
-S: 4a OK \[READ-WRITE\] SELECT completed
+S: 4a OK \[READ-WRITE\] SELECT completed.
 
 SESSION: 1
 C: 1c APPEND existsresponse {310+}
@@ -68,43 +65,43 @@
 C:
 C: Hello Joe, do you think we can meet at 3:30 tomorrow?
 C:
-S: 1c OK APPEND completed
+S: 1c OK APPEND completed.
 
 C: 1b STATUS existsresponse (MESSAGES RECENT)
-S: \* STATUS existsresponse \(MESSAGES 1 RECENT 1\)
-S: 1b OK STATUS completed
+S: \* STATUS \"existsresponse\" \(MESSAGES 1 RECENT 1\)
+S: 1b OK STATUS completed.
 
 # EXISTS response on NOOP
 SESSION: 2
 C: 2b NOOP
 S: \* 1 EXISTS
-S: \* 1 RECENT
-S: 2b OK NOOP completed
+S: \* 0 RECENT
+S: 2b OK NOOP completed.
 
 C: 2c CLOSE
-S: 2c OK CLOSE completed
+S: 2c OK CLOSE completed.
 
 # EXISTS response on STORE (recent is no longer set)
 SESSION: 3
 C: 3b STORE 1 +FLAGS.SILENT (\Flagged)
 S: \* 1 EXISTS
 S: \* 0 RECENT
-S: 3b OK STORE completed
+S: 3b OK STORE completed.
 
 C: 3c CLOSE
-S: 3c OK CLOSE completed
+S: 3c OK CLOSE completed.
 
 # EXISTS response on CREATE
 SESSION: 4
 C: 4b CREATE another
 S: \* 1 EXISTS
 S: \* 0 RECENT
-S: \* 1 FETCH \(FLAGS \(\\Flagged\)
-S: 4b OK CREATE completed
+S: \* 1 FETCH \(FLAGS \(\\Flagged\)\)
+S: 4b OK CREATE completed.
 
 C: 4c DELETE another
-S: 4c OK DELETE completed
+S: 4c OK DELETE completed.
 
 C: 4c DELETE existsresponse
-S: 4c OK DELETE completed
+S: 4c OK DELETE completed.
 

Copied: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentFetchResponse.test (from r682165, james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/concurrent/FetchResponse.test)
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentFetchResponse.test?p2=james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentFetchResponse.test&p1=james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/concurrent/FetchResponse.test&r1=682165&r2=682219&rev=682219&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/concurrent/FetchResponse.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentFetchResponse.test Sun Aug  3 14:21:45 2008
@@ -23,8 +23,8 @@
 S: 1a OK CREATE completed.
 
 C: 1b STATUS multibox (MESSAGES)
-S: \* STATUS multibox \(MESSAGES 0\)
-S: 1b OK STATUS completed
+S: \* STATUS "multibox" \(MESSAGES 0\)
+S: 1b OK STATUS completed.
 
 C: 1c APPEND multibox {310+}
 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
@@ -37,7 +37,7 @@
 C:
 C: Hello Joe, do you think we can meet at 3:30 tomorrow?
 C:
-S: 1c OK APPEND completed
+S: 1c OK APPEND completed.
 
 C: 1c APPEND multibox {312+}
 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
@@ -50,16 +50,16 @@
 C:
 C: Hello Joe, do you think we can meet at 3:30 tomorrow?
 C:
-S: 1c OK APPEND completed
+S: 1c OK APPEND completed.
 
 C: 1d SELECT multibox
 S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
 S: \* 2 EXISTS
 S: \* 2 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
+S: \* OK \[UNSEEN 1\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
-S: 1d OK \[READ-WRITE\] SELECT completed
+S: 1d OK \[READ-WRITE\] SELECT completed.
 
 SESSION: 2
 C: 2a SELECT multibox
@@ -67,9 +67,9 @@
 S: \* 2 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
+S: \* OK \[UNSEEN 1\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
-S: 2a OK \[READ-WRITE\] SELECT completed
+S: 2a OK \[READ-WRITE\] SELECT completed.
 
 SESSION: 3
 C: 3a SELECT multibox
@@ -77,9 +77,9 @@
 S: \* 2 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
+S: \* OK \[UNSEEN 1\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
-S: 3a OK \[READ-WRITE\] SELECT completed
+S: 3a OK \[READ-WRITE\] SELECT completed.
 
 SESSION: 4
 C: 4a SELECT multibox
@@ -87,66 +87,66 @@
 S: \* 2 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
+S: \* OK \[UNSEEN 1\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
-S: 4a OK \[READ-WRITE\] SELECT completed
+S: 4a OK \[READ-WRITE\] SELECT completed.
 
 SESSION: 1
 C: 1e STORE 1 FLAGS (\Flagged)
-S: \* 1 FETCH \(FLAGS \(\\Flagged\)\)
-S: 1e OK STORE completed
+S: \* 1 FETCH \(FLAGS \(\\Flagged \\Recent\)\)
+S: 1e OK STORE completed.
 
 # On NOOP, we get the Fetch Response from the Session1 update.
 SESSION: 2
 C: 2b NOOP
 S: \* 1 FETCH \(FLAGS \(\\Flagged\)\)
-S: 2b OK NOOP completed
+S: 2b OK NOOP completed.
 
 # On STORE, we get the Fetch Response from the Session1 update.
 SESSION: 3
 C: 3b COPY 2 inbox
 S: \* 1 FETCH \(FLAGS \(\\Flagged\)\)
-S: 3b OK COPY completed
+S: 3b OK COPY completed.
 
 # Update another flag, this time SILENT 
 # Still get notifications on *other* sessions, but not this one.
 SESSION: 1
 C: 1e STORE 2 FLAGS.SILENT (\Flagged)
-S: 1e OK STORE completed
+S: 1e OK STORE completed.
 
 # We should only get one flag notification on SESSION 2,
 # but 2 notifications on SESSION 4.
 SESSION: 2
 C: 2b NOOP
 S: \* 2 FETCH \(FLAGS \(\\Flagged\)\)
-S: 2b OK NOOP completed
+S: 2b OK NOOP completed.
 
 # On CREATE, we get the Fetch Response from both of the Session1 updates.
 SESSION: 4
 C: 4b CREATE another
 S: \* 1 FETCH \(FLAGS \(\\Flagged\)\)
 S: \* 2 FETCH \(FLAGS \(\\Flagged\)\)
-S: 4b OK CREATE completed
+S: 4b OK CREATE completed.
 
 C: 4c DELETE another
-S: 4c OK DELETE completed
+S: 4c OK DELETE completed.
 
 SESSION: 1
 C: 1f CLOSE
-S: 1f OK CLOSE completed
+S: 1f OK CLOSE completed.
 
 SESSION: 2
 C: 2c CLOSE
-S: 2c OK CLOSE completed
+S: 2c OK CLOSE completed.
 
 SESSION: 3
 C: 3c CLOSE
-S: 3c OK CLOSE completed
+S: 3c OK CLOSE completed.
 
 SESSION: 4
 C: 4c CLOSE
-S: 4c OK CLOSE completed
+S: 4c OK CLOSE completed.
 
 SESSION: 1
 C: 1g DELETE multibox
-S: 1g OK DELETE completed
\ No newline at end of file
+S: 1g OK DELETE completed.
\ No newline at end of file

Copied: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentRenameSelected.test (from r682165, james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/concurrent/RenameSelected.test)
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentRenameSelected.test?p2=james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentRenameSelected.test&p1=james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/concurrent/RenameSelected.test&r1=682165&r2=682219&rev=682219&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/concurrent/RenameSelected.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ConcurrentRenameSelected.test Sun Aug  3 14:21:45 2008
@@ -23,7 +23,7 @@
 
 SESSION: 1
 C: 1a CREATE renameconcurrent
-S: 1a OK CREATE completed
+S: 1a OK CREATE completed.
 
 C: 1b APPEND renameconcurrent (\Deleted) {254+}
 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
@@ -36,28 +36,28 @@
 C:
 C: Test 03
 C:
-S: 1b OK APPEND completed
+S: 1b OK APPEND completed.
 
 C: 1c SELECT renameconcurrent
 S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
 S: \* 1 EXISTS
 S: \* 1 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
+S: \* OK \[UNSEEN 1\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
-S: 1c OK \[READ-WRITE\] SELECT completed
+S: 1c OK \[READ-WRITE\] SELECT completed.
 
 
 # Client #1 has mailbox "renameconcurrent" selected. Client #2 RENAMEs the mailbox.
 SESSION: 2
 C: 2a RENAME renameconcurrent renamed
-S: 2a OK RENAME completed
+S: 2a OK RENAME completed.
 
 # Client #1 is still able to do operations that do not reference the mailbox name.
 SESSION: 1
 C: 1d FETCH 1:* (FLAGS)
-S: \* 1 FETCH \(FLAGS \(\\Deleted\)\)
-S: 1d OK FETCH completed
+S: \* 1 FETCH \(FLAGS \(\\Recent\)\)
+S: 1d OK FETCH completed.
 
 # Client #1 is not able to do operations that reference the mailbox name.
 C: 1e APPEND renameconcurrent (\Deleted) {254+}

Modified: james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/process/SelectedImapMailbox.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/process/SelectedImapMailbox.java?rev=682219&r1=682218&r2=682219&view=diff
==============================================================================
--- james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/process/SelectedImapMailbox.java (original)
+++ james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/process/SelectedImapMailbox.java Sun Aug  3 14:21:45 2008
@@ -43,4 +43,11 @@
     public String getName();
 
     public boolean isRecent(long uid);
+    
+    /**
+     * Is the mailbox deleted?
+     * @return true when the mailbox has been deleted by another session, 
+     * false otherwise
+     */
+    public boolean isDeletedByOtherSession();
 }
\ No newline at end of file

Modified: james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/base/SelectedMailboxSessionImpl.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/base/SelectedMailboxSessionImpl.java?rev=682219&r1=682218&r2=682219&view=diff
==============================================================================
--- james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/base/SelectedMailboxSessionImpl.java (original)
+++ james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/base/SelectedMailboxSessionImpl.java Sun Aug  3 14:21:45 2008
@@ -117,6 +117,15 @@
         return converter.getMsn(uid);
     }
     
+    /**
+     * Is the mailbox deleted?
+     * @return true when the mailbox has been deleted by another session, 
+     * false otherwise
+     */
+    public boolean isDeletedByOtherSession() {
+        return events.isDeletedByOtherSession();
+    }
+    
     private void addExpungedResponses(List responses, final Mailbox mailbox) {
         for  (Iterator it = events.expungedUids(); it.hasNext();) {
             final Long uid = (Long) it.next();
@@ -160,6 +169,11 @@
             } else {
                 uidOut = null;
             }
+            if (isRecent(uid)) {
+                flags.add(Flags.Flag.RECENT);
+            } else {
+                flags.remove(Flags.Flag.RECENT);
+            }
             FetchResponse response = new FetchResponse(msn, flags, uidOut, null, null, null, null, null, null);
             responses.add(response);
         }

Modified: james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/CreateProcessor.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/CreateProcessor.java?rev=682219&r1=682218&r2=682219&view=diff
==============================================================================
--- james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/CreateProcessor.java (original)
+++ james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/CreateProcessor.java Sun Aug  3 14:21:45 2008
@@ -51,8 +51,8 @@
             final String fullMailboxName = buildFullName(session, mailboxName);
             final MailboxManager mailboxManager = getMailboxManager(session);
             mailboxManager.createMailbox(fullMailboxName);
-            okComplete(command, tag, responder);
             unsolicitedResponses(session, responder, false);
+            okComplete(command, tag, responder);
         } catch (MailboxManagerException e) {
             no(command, tag, responder, e);
         }

Modified: james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/DeleteProcessor.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/DeleteProcessor.java?rev=682219&r1=682218&r2=682219&view=diff
==============================================================================
--- james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/DeleteProcessor.java (original)
+++ james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/DeleteProcessor.java Sun Aug  3 14:21:45 2008
@@ -56,7 +56,7 @@
                 }
             }
             final MailboxManager mailboxManager = getMailboxManager(session);
-            mailboxManager.deleteMailbox(fullMailboxName);
+            mailboxManager.deleteMailbox(fullMailboxName, ImapSessionUtils.getMailboxSession(session));
             unsolicitedResponses(session, responder, false);
             okComplete(command, tag, responder);
             

Modified: james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/commands/DeleteCommand.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/commands/DeleteCommand.java?rev=682219&r1=682218&r2=682219&view=diff
==============================================================================
--- james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/commands/DeleteCommand.java (original)
+++ james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/commands/DeleteCommand.java Sun Aug  3 14:21:45 2008
@@ -55,7 +55,7 @@
                     session.deselect();
                 }
             }
-            session.getMailboxManager().deleteMailbox(mailboxName);
+            session.getMailboxManager().deleteMailbox(mailboxName, null);
         } catch (MailboxManagerException e) {
             throw new MailboxException(e);
         }

Modified: james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/MailboxListener.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/MailboxListener.java?rev=682219&r1=682218&r2=682219&view=diff
==============================================================================
--- james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/MailboxListener.java (original)
+++ james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/MailboxListener.java Sun Aug  3 14:21:45 2008
@@ -44,6 +44,11 @@
     }
     
     /**
+     * Indicates that mailbox has been deleted.
+     */
+    public interface MailboxDeletionEvent extends Event {}
+    
+    /**
      * A mailbox event related to a message.
      */
     public interface MessageEvent extends Event {

Modified: james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/impl/MailboxEventDispatcher.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/impl/MailboxEventDispatcher.java?rev=682219&r1=682218&r2=682219&view=diff
==============================================================================
--- james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/impl/MailboxEventDispatcher.java (original)
+++ james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/impl/MailboxEventDispatcher.java Sun Aug  3 14:21:45 2008
@@ -215,4 +215,25 @@
         }
     }
 
+    public void mailboxDeleted(long sessionId) {
+        final MailboxDeletionEventImpl event = new MailboxDeletionEventImpl(sessionId);
+        for (Iterator iter = listeners.iterator(); iter.hasNext();) {
+            MailboxListener mailboxListener = (MailboxListener) iter.next();
+            mailboxListener.event(event);
+        }
+    }
+
+    private static final class MailboxDeletionEventImpl implements  MailboxListener.MailboxDeletionEvent {
+        private final long sessionId;
+        
+        public MailboxDeletionEventImpl(final long sessionId) {
+            super();
+            this.sessionId = sessionId;
+        }
+
+        public long getSessionId() {
+            return sessionId;
+        }
+        
+    }
 }

Modified: james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/manager/MailboxManager.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/manager/MailboxManager.java?rev=682219&r1=682218&r2=682219&view=diff
==============================================================================
--- james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/manager/MailboxManager.java (original)
+++ james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/manager/MailboxManager.java Sun Aug  3 14:21:45 2008
@@ -95,7 +95,7 @@
      */
     void createMailbox(String mailboxName) throws MailboxManagerException;
 
-    void deleteMailbox(String mailboxName) throws MailboxManagerException;
+    void deleteMailbox(String mailboxName, MailboxSession session) throws MailboxManagerException;
 
     /**
      * Renames a mailbox. 

Modified: james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/util/MailboxEventAnalyser.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/util/MailboxEventAnalyser.java?rev=682219&r1=682218&r2=682219&view=diff
==============================================================================
--- james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/util/MailboxEventAnalyser.java (original)
+++ james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/util/MailboxEventAnalyser.java Sun Aug  3 14:21:45 2008
@@ -29,6 +29,7 @@
 
 public class MailboxEventAnalyser implements MailboxListener {
 
+    private boolean isDeletedByOtherSession = false;
     private boolean sizeChanged = false;
     private boolean silentFlagChanges = false;
     private final long sessionId;
@@ -45,10 +46,10 @@
     }
 
     public void event(Event event) {
+        final long eventSessionId = event.getSessionId();
         if (event instanceof MessageEvent) {
             final MessageEvent messageEvent = (MessageEvent) event;
             final long uid =  messageEvent.getSubjectUid();
-            final long eventSessionId = messageEvent.getSessionId();
             if (messageEvent instanceof Added) {
                 sizeChanged = true;
             } else if (messageEvent instanceof FlagsUpdated) {
@@ -62,6 +63,10 @@
                 final Long uidObject = new Long(uid);
                 expungedUids.add(uidObject);
             }
+        } else if (event instanceof MailboxDeletionEvent) {
+            if (eventSessionId != sessionId) {
+                isDeletedByOtherSession = true;
+            }
         }
     }
 
@@ -85,6 +90,7 @@
         sizeChanged = false;
         flagUpdateUids.clear();
         expungedUids.clear();
+        isDeletedByOtherSession = false;
     }
     
     /**
@@ -113,6 +119,15 @@
     public final boolean isSizeChanged() {
         return sizeChanged;
     }
+    
+    /**
+     * Is the mailbox deleted?
+     * @return true when the mailbox has been deleted by another session, 
+     * false otherwise
+     */
+    public final boolean isDeletedByOtherSession() {
+        return isDeletedByOtherSession;
+    }
 
     public Iterator flagUpdateUids() {
         return flagUpdateUids.iterator();
@@ -125,14 +140,4 @@
     public boolean hasExpungedUids() {
         return !expungedUids.isEmpty();
     }
-    
-    public void mailboxDeleted() {
-        // TODO implementation
-
-    }
-
-    public void mailboxRenamed(String origName, String newName) {
-        // TODO implementation
-
-    }
 }

Modified: james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/util/UidChangeTracker.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/util/UidChangeTracker.java?rev=682219&r1=682218&r2=682219&view=diff
==============================================================================
--- james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/util/UidChangeTracker.java (original)
+++ james/server/trunk/mailbox-library/src/main/java/org/apache/james/mailboxmanager/util/UidChangeTracker.java Sun Aug  3 14:21:45 2008
@@ -215,12 +215,16 @@
         return lastScannedUid;
     }
 
-    public void addMailboxListener(MailboxListener listener) {
+    public synchronized void addMailboxListener(MailboxListener listener) {
         eventDispatcher.addMailboxListener(listener);
     }
 
-    public void removeMailboxListener(MailboxListener listener) {
+    public synchronized void removeMailboxListener(MailboxListener listener) {
         eventDispatcher.removeMailboxListener(listener);
     }
 
+    public synchronized void mailboxDeleted(long sessionId) {
+        eventDispatcher.mailboxDeleted(sessionId);
+    }
+
 }

Modified: james/server/trunk/mailbox-library/src/test/java/org/apache/james/mailboxmanager/util/MailboxEventAnalyserTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailbox-library/src/test/java/org/apache/james/mailboxmanager/util/MailboxEventAnalyserTest.java?rev=682219&r1=682218&r2=682219&view=diff
==============================================================================
--- james/server/trunk/mailbox-library/src/test/java/org/apache/james/mailboxmanager/util/MailboxEventAnalyserTest.java (original)
+++ james/server/trunk/mailbox-library/src/test/java/org/apache/james/mailboxmanager/util/MailboxEventAnalyserTest.java Sun Aug  3 14:21:45 2008
@@ -26,8 +26,11 @@
 import org.apache.james.mailboxmanager.MailboxListener;
 import org.apache.james.mailboxmanager.MockMailboxListenerAdded;
 import org.apache.james.mailboxmanager.MockMailboxListenerFlagsUpdate;
+import org.jmock.Mock;
 import org.jmock.MockObjectTestCase;
 
+import com.sun.org.apache.bcel.internal.generic.LALOAD;
+
 public class MailboxEventAnalyserTest extends MockObjectTestCase {
 
     private static final long BASE_SESSION_ID = 99;
@@ -44,7 +47,9 @@
     }
 
     public void testShouldBeNoSizeChangeOnOtherEvent() throws Exception {
-        analyser.event((MailboxListener.Event) mock(MailboxListener.Event.class).proxy());
+        final Mock mock = mock(MailboxListener.Event.class);
+        mock.expects(atLeastOnce()).method("getSessionId").will(returnValue(11L));
+        analyser.event((MailboxListener.Event) mock.proxy());
         assertFalse(analyser.isSizeChanged());
     }
     

Modified: james/server/trunk/phoenix-deployment/src/test/org/apache/james/experimental/imapserver/ExperimentalHostSystem.java
URL: http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/test/org/apache/james/experimental/imapserver/ExperimentalHostSystem.java?rev=682219&r1=682218&r2=682219&view=diff
==============================================================================
--- james/server/trunk/phoenix-deployment/src/test/org/apache/james/experimental/imapserver/ExperimentalHostSystem.java (original)
+++ james/server/trunk/phoenix-deployment/src/test/org/apache/james/experimental/imapserver/ExperimentalHostSystem.java Sun Aug  3 14:21:45 2008
@@ -46,7 +46,6 @@
     private ImapEncoder encoder;
     private ImapProcessor processor;
     private Resetable dataReset;
-    private boolean isReadLast = true;
     private final Set users;
     
     public ExperimentalHostSystem() {
@@ -232,7 +231,7 @@
         ByteBufferInputStream in;
         ImapRequestHandler handler;
         ImapSessionImpl session;
-        
+        boolean isReadLast = true;
         
         public Session(Continuation continuation) {
             out = new ByteBufferOutputStream(continuation);

Modified: james/server/trunk/phoenix-deployment/src/test/org/apache/james/mailboxmanager/torque/TorqueMailboxManagerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/test/org/apache/james/mailboxmanager/torque/TorqueMailboxManagerTest.java?rev=682219&r1=682218&r2=682219&view=diff
==============================================================================
--- james/server/trunk/phoenix-deployment/src/test/org/apache/james/mailboxmanager/torque/TorqueMailboxManagerTest.java (original)
+++ james/server/trunk/phoenix-deployment/src/test/org/apache/james/mailboxmanager/torque/TorqueMailboxManagerTest.java Sun Aug  3 14:21:45 2008
@@ -45,7 +45,7 @@
         assertEquals(1,l.size());
         assertEquals("#users.tuser2.INBOX",((MailboxRow)l.get(0)).getName());
         
-        mm.deleteMailbox("#users.tuser2.INBOX");
+        mm.deleteMailbox("#users.tuser2.INBOX", null);
         l=MailboxRowPeer.doSelect(new Criteria());
         assertEquals(0,l.size());
     }

Modified: james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java
URL: http://svn.apache.org/viewvc/james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java?rev=682219&r1=682218&r2=682219&view=diff
==============================================================================
--- james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java (original)
+++ james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java Sun Aug  3 14:21:45 2008
@@ -80,7 +80,7 @@
 
     private MailboxRow mailboxRow;
 
-    private UidChangeTracker tracker;
+    private final UidChangeTracker tracker;
 
     private final ReadWriteLock lock;
     
@@ -785,4 +785,8 @@
             throw new MailboxManagerException(e);
         }
     }
+
+    public void deleted(MailboxSession session) {
+        tracker.mailboxDeleted(session.getSessionId());
+    }
 }
\ No newline at end of file

Modified: james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
URL: http://svn.apache.org/viewvc/james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java?rev=682219&r1=682218&r2=682219&view=diff
==============================================================================
--- james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java (original)
+++ james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java Sun Aug  3 14:21:45 2008
@@ -144,7 +144,7 @@
         }
     }
 
-    public void deleteMailbox(String mailboxName)
+    public void deleteMailbox(String mailboxName, MailboxSession session)
             throws MailboxManagerException {
         getLog().info("deleteMailbox "+mailboxName);
         synchronized (managers) {
@@ -155,7 +155,10 @@
                     throw new MailboxNotFoundException("Mailbox not found");
                 }
                 MailboxRowPeer.doDelete(mr);
-                managers.remove(mailboxName);
+                TorqueMailbox mailbox = (TorqueMailbox) managers.remove(mailboxName);
+                if (mailbox != null) {
+                    mailbox.deleted(session);
+                }
             } catch (TorqueException e) {
                 throw new MailboxManagerException(e);
             }



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: svn commit: r682219 - in /james/server/trunk: core-library/src/main/java/org/apache/james/core/ experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ experimental-seda-imap-function/src/test/java/org/apache/james/test/...

Posted by Stefano Bagnara <ap...@bago.org>.
rdonkin@apache.org ha scritto:
> Author: rdonkin
> Date: Sun Aug  3 14:21:45 2008
> New Revision: 682219
> 
> URL: http://svn.apache.org/viewvc?rev=682219&view=rev
> Log:
> Concurrency tests for IMAP
 > [...]
> Modified:
>     james/server/trunk/core-library/src/main/java/org/apache/james/core/MailImpl.java
> [...]

This commit included the changes you did to MailImpl working on 
JAMES-850. I don't know if this is by purpose or by mistake, but I'm not 
sure they are good in the long term unless there is a need (unless they 
fix the issue, because the "full clone" on MailImpl was introduced for 
performance issues).

Stefano

> Modified: james/server/trunk/core-library/src/main/java/org/apache/james/core/MailImpl.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/core-library/src/main/java/org/apache/james/core/MailImpl.java?rev=682219&r1=682218&r2=682219&view=diff
> ==============================================================================
> --- james/server/trunk/core-library/src/main/java/org/apache/james/core/MailImpl.java (original)
> +++ james/server/trunk/core-library/src/main/java/org/apache/james/core/MailImpl.java Sun Aug  3 14:21:45 2008
> @@ -28,6 +28,7 @@
>  import org.apache.mailet.RFC2822Headers;
>  
>  import javax.mail.MessagingException;
> +import javax.mail.SendFailedException;
>  import javax.mail.internet.InternetAddress;
>  import javax.mail.internet.MimeMessage;
>  import javax.mail.internet.ParseException;
> @@ -158,16 +159,19 @@
>          setRemoteAddr(mail.getRemoteAddr());
>          setLastUpdated(mail.getLastUpdated());
>          try {
> -            if (mail instanceof MailImpl) {
> -                setAttributesRaw((HashMap) cloneSerializableObject(((MailImpl) mail).getAttributesRaw()));
> -            } else {
> -                HashMap attribs = new HashMap();
> -                for (Iterator i = mail.getAttributeNames(); i.hasNext(); ) {
> -                    String hashKey = (String) i.next();
> -                    attribs.put(hashKey,cloneSerializableObject(mail.getAttribute(hashKey)));
> +            HashMap attribs = new HashMap();
> +            for (Iterator i = mail.getAttributeNames(); i.hasNext(); ) {
> +                String hashKey = (String) i.next();
> +                final Serializable attribute = mail.getAttribute(hashKey);
> +                if (attribute instanceof SendFailedException) {
> +                    SendFailedException ex = (SendFailedException) attribute;
> +                    Throwable t = ex.getNextException();
> +                    debug(t); 
>                  }
> -                setAttributesRaw(attribs);
> +                final Object cloneSerializableObject = cloneSerializableObject(attribute);
> +                attribs.put(hashKey,cloneSerializableObject);
>              }
> +            setAttributesRaw(attribs);
>          } catch (IOException e) {
>              // should never happen for in memory streams
>              setAttributesRaw(new HashMap());
> @@ -176,6 +180,28 @@
>              setAttributesRaw(new HashMap());
>          }
>      }
> +    private void debug(Throwable t) {
> +        if (t == null) {
> +            System.err.println("[END]");
> +        } else {
> +            System.err.println("NEXT@" + System.identityHashCode(t)  + t );
> +            if (t instanceof MessagingException) {
> +                MessagingException e = (MessagingException) t;
> +                System.err.println("NEXT@" + System.identityHashCode(e)  + e );
> +                t = e.getNextException();
> +                if (t == null) {
> +                    t = e.getCause();
> +                }
> +                debug(t);
> +            } else {
> +                System.err.println("NEXT@" + System.identityHashCode(t)  + t );
> +                Throwable next = t.getCause();
> +                if (next != t) {
> +                    debug(next);
> +                }
> +            }
> +        }
> +    }
>  
>      /**
>       * A constructor that creates a MailImpl with the specified name,
> @@ -608,7 +634,7 @@
>       * @throws IOException
>       * @throws ClassNotFoundException
>       */
> -    private static Object cloneSerializableObject(Object o) throws IOException, ClassNotFoundException {
> +    public static Object cloneSerializableObject(Object o) throws IOException, ClassNotFoundException {
>          ByteArrayOutputStream b = new ByteArrayOutputStream();
>          ObjectOutputStream out = new ObjectOutputStream(b);
>          out.writeObject(o);
> [...]


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org