activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r634487 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicSubscription.java
Date Fri, 07 Mar 2008 00:57:56 GMT
Author: rajdavies
Date: Thu Mar  6 16:57:55 2008
New Revision: 634487

URL: http://svn.apache.org/viewvc?rev=634487&view=rev
Log:
resolve concurrent modification

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicSubscription.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicSubscription.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicSubscription.java?rev=634487&r1=634486&r2=634487&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicSubscription.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicSubscription.java
Thu Mar  6 16:57:55 2008
@@ -17,6 +17,7 @@
 package org.apache.activemq.broker.region;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -110,12 +111,19 @@
                             // only page in a 1000 at a time - else we could
                             // blow da memory
                             pageInSize = Math.max(1000, pageInSize);
-                            LinkedList list = matched.pageInList(pageInSize);
-                            MessageReference[] oldMessages = messageEvictionStrategy.evictMessages(list);
-                            int messagesToEvict = oldMessages.length;
-                            for (int i = 0; i < messagesToEvict; i++) {
-                                MessageReference oldMessage = oldMessages[i];
-                                discard(oldMessage);
+                            LinkedList list = null;
+                            MessageReference[] oldMessages=null;
+                            synchronized(matched){
+                            list = matched.pageInList(pageInSize);
+                            	oldMessages = messageEvictionStrategy.evictMessages(list);
+                            }
+                            int messagesToEvict = 0;
+                            if (oldMessages != null){
+	                            messagesToEvict = oldMessages.length;
+	                            for (int i = 0; i < messagesToEvict; i++) {
+	                                MessageReference oldMessage = oldMessages[i];
+	                                discard(oldMessage);
+	                            }
                             }
                             // lets avoid an infinite loop if we are given a bad
                             // eviction strategy
@@ -454,7 +462,11 @@
      * @return the list
      */
     public synchronized List<MessageReference> getInFlightMessages(){
-        return matched.pageInList(1000);
+    	List<MessageReference> result = new ArrayList<MessageReference>();
+        synchronized(matched) {
+            result.addAll(matched.pageInList(1000));
+        }
+        return result;
     }
 
 }



Mime
View raw message