james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1146240 - /james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/MailboxEventAnalyser.java
Date Wed, 13 Jul 2011 19:08:31 GMT
Author: norman
Date: Wed Jul 13 19:08:31 2011
New Revision: 1146240

URL: http://svn.apache.org/viewvc?rev=1146240&view=rev
Log:
Make sure the MailboxEventAnalyser is 100% thread-safe. See IMAP-320

Modified:
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/MailboxEventAnalyser.java

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/MailboxEventAnalyser.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/MailboxEventAnalyser.java?rev=1146240&r1=1146239&r2=1146240&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/MailboxEventAnalyser.java
(original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/MailboxEventAnalyser.java
Wed Jul 13 19:08:31 2011
@@ -109,9 +109,7 @@ public class MailboxEventAnalyser extend
                         for (int i = 0; i < uFlags.size(); i++) {
                             UpdatedFlags u = uFlags.get(i);
                             if (interestingFlags(u)) {
-                                synchronized (flagUpdateUids) {
-                                    flagUpdateUids.add(u.getUid());
-                                }
+                                flagUpdateUids.add(u.getUid());
                                 
                             }
                         }
@@ -141,29 +139,27 @@ public class MailboxEventAnalyser extend
                         }
                     }
                     
+                    int size = applicableFlags.getUserFlags().length;
+                    FlagsUpdated updatedF = (FlagsUpdated) messageEvent;
+                    List<UpdatedFlags> flags = updatedF.getUpdatedFlags();
+
+                    for (int i = 0; i < flags.size(); i++) {
+                        applicableFlags.add(flags.get(i).getNewFlags());
+
+                    }
+
+                    // \RECENT is not a applicable flag in imap so remove it
+                    // from the list
+                    applicableFlags.remove(Flags.Flag.RECENT);
 
-                    synchronized (applicableFlags) {
-                        int size = applicableFlags.getUserFlags().length;
-                        FlagsUpdated updatedF = (FlagsUpdated) messageEvent;
-                        List<UpdatedFlags> flags = updatedF.getUpdatedFlags();
-                        
-                       for (int i = 0; i < flags.size(); i++) {
-                          applicableFlags.add(flags.get(i).getNewFlags());
-
-                       }
-                       
-                       // \RECENT is not a applicable flag in imap so remove it from the
list
-                       applicableFlags.remove(Flags.Flag.RECENT);
-                       
-                       if (size < applicableFlags.getUserFlags().length) {
-                          applicableFlagsChanged = true;
-                       }
+                    if (size < applicableFlags.getUserFlags().length) {
+                        applicableFlagsChanged = true;
                     }
                     
+                    
                 } else if (messageEvent instanceof Expunged) {
-                    synchronized (expungedUids) {
-                        expungedUids.addAll(messageEvent.getUids());
-                    }
+                    expungedUids.addAll(messageEvent.getUids());
+                    
                 }
             } else if (event instanceof MailboxDeletion) {
                 if (eventSessionId != sessionId) {
@@ -217,7 +213,7 @@ public class MailboxEventAnalyser extend
      * @return true if any flag changes from current session will be ignored,
      *         false otherwise
      */
-    public final boolean isSilentFlagChanges() {
+    public synchronized final boolean isSilentFlagChanges() {
         return silentFlagChanges;
     }
 
@@ -228,7 +224,7 @@ public class MailboxEventAnalyser extend
      *            true if any flag changes from current session should be
      *            ignored, false otherwise
      */
-    public final void setSilentFlagChanges(boolean silentFlagChanges) {
+    public synchronized final void setSilentFlagChanges(boolean silentFlagChanges) {
         this.silentFlagChanges = silentFlagChanges;
     }
 
@@ -237,7 +233,7 @@ public class MailboxEventAnalyser extend
      * 
      * @return true if new messages have been added, false otherwise
      */
-    public final boolean isSizeChanged() {
+    public synchronized final boolean isSizeChanged() {
         return sizeChanged;
     }
 
@@ -247,7 +243,7 @@ public class MailboxEventAnalyser extend
      * @return true when the mailbox has been deleted by another session, false
      *         otherwise
      */
-    public final boolean isDeletedByOtherSession() {
+    public synchronized final boolean isDeletedByOtherSession() {
         return isDeletedByOtherSession;
     }
 
@@ -257,13 +253,12 @@ public class MailboxEventAnalyser extend
      * @return uids
      */
 
-    public Collection<Long> flagUpdateUids() {
-        synchronized (flagUpdateUids) {
-            // copy the TreeSet to fix possible
-            // java.util.ConcurrentModificationException
-            // See IMAP-278
-            return Collections.unmodifiableSet(new TreeSet<Long>(flagUpdateUids));
-        }
+    public synchronized Collection<Long> flagUpdateUids() {
+        // copy the TreeSet to fix possible
+        // java.util.ConcurrentModificationException
+        // See IMAP-278
+        return Collections.unmodifiableSet(new TreeSet<Long>(flagUpdateUids));
+        
     }
 
     /**
@@ -271,13 +266,12 @@ public class MailboxEventAnalyser extend
      * 
      * @return uids
      */
-    public Collection<Long> expungedUids() {
-        synchronized (expungedUids) {
-            // copy the TreeSet to fix possible
-            // java.util.ConcurrentModificationException
-            // See IMAP-278
-            return Collections.unmodifiableSet(new TreeSet<Long>(expungedUids));
-        }
+    public synchronized Collection<Long> expungedUids() {
+        // copy the TreeSet to fix possible
+        // java.util.ConcurrentModificationException
+        // See IMAP-278
+        return Collections.unmodifiableSet(new TreeSet<Long>(expungedUids));
+        
     }
 
     /**
@@ -285,10 +279,9 @@ public class MailboxEventAnalyser extend
      * 
      * @return hasUids
      */
-    public boolean hasExpungedUids() {
-        synchronized (expungedUids) {
-            return !expungedUids.isEmpty();
-        }
+    public synchronized boolean hasExpungedUids() {
+        return !expungedUids.isEmpty();
+        
     }
 
     /**
@@ -297,11 +290,9 @@ public class MailboxEventAnalyser extend
     public synchronized void close() {
         closed = true;
         flagUpdateUids.clear();
-        flagUpdateUids = null;
 
         uninterestingFlag = null;
         expungedUids.clear();
-        expungedUids = null;
     }
 
     /*



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


Mime
View raw message