activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From martyntay...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-1029 Cleaning up small possible Exception
Date Fri, 10 Mar 2017 11:09:47 GMT
ARTEMIS-1029 Cleaning up small possible Exception

treating an exception after the PagingIterator in case of duplicates cleanups


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/f1249e39
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/f1249e39
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/f1249e39

Branch: refs/heads/master
Commit: f1249e39a95a525b820ca8ff2296855f4f8b7ecb
Parents: 526b42a
Author: Clebert Suconic <clebertsuconic@apache.org>
Authored: Thu Mar 9 22:34:56 2017 -0500
Committer: Martyn Taylor <mtaylor@redhat.com>
Committed: Fri Mar 10 11:09:29 2017 +0000

----------------------------------------------------------------------
 .../core/management/impl/QueueControlImpl.java  | 41 +++++++++++++-------
 .../core/server/impl/ScaleDownHandler.java      |  6 ++-
 2 files changed, 33 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f1249e39/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
index 5ecea64..c5f2111 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
@@ -29,6 +29,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.NoSuchElementException;
 
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.JsonUtil;
@@ -434,12 +435,16 @@ public class QueueControlImpl extends AbstractControl implements QueueControl
{
          List<Map<String, Object>> messages = new ArrayList<>();
          queue.flushExecutor();
          try (LinkedListIterator<MessageReference> iterator = queue.browserIterator())
{
-            while (iterator.hasNext()) {
-               MessageReference ref = iterator.next();
-               if (filter == null || filter.match(ref.getMessage())) {
-                  Message message = ref.getMessage();
-                  messages.add(message.toMap());
+            try {
+               while (iterator.hasNext()) {
+                  MessageReference ref = iterator.next();
+                  if (filter == null || filter.match(ref.getMessage())) {
+                     Message message = ref.getMessage();
+                     messages.add(message.toMap());
+                  }
                }
+            } catch (NoSuchElementException ignored) {
+               // this could happen through paging browsing
             }
             return messages.toArray(new Map[messages.size()]);
          }
@@ -524,11 +529,16 @@ public class QueueControlImpl extends AbstractControl implements QueueControl
{
          } else {
             try (LinkedListIterator<MessageReference> iterator = queue.browserIterator())
{
                int count = 0;
-               while (iterator.hasNext()) {
-                  MessageReference ref = iterator.next();
-                  if (filter.match(ref.getMessage())) {
-                     count++;
+
+               try {
+                  while (iterator.hasNext()) {
+                     MessageReference ref = iterator.next();
+                     if (filter.match(ref.getMessage())) {
+                        count++;
+                     }
                   }
+               } catch (NoSuchElementException ignored) {
+                  // this could happen through paging browsing
                }
                return count;
             }
@@ -928,13 +938,18 @@ public class QueueControlImpl extends AbstractControl implements QueueControl
{
          Filter thefilter = FilterImpl.createFilter(filter);
          queue.flushExecutor();
          try (LinkedListIterator<MessageReference> iterator = queue.browserIterator())
{
-            while (iterator.hasNext() && currentPageSize++ < pageSize) {
-               MessageReference ref = iterator.next();
-               if (thefilter == null || thefilter.match(ref.getMessage())) {
-                  c.add(OpenTypeSupport.convert(ref));
+            try {
+               while (iterator.hasNext() && currentPageSize++ < pageSize) {
+                  MessageReference ref = iterator.next();
+                  if (thefilter == null || thefilter.match(ref.getMessage())) {
+                     c.add(OpenTypeSupport.convert(ref));
 
+                  }
                }
+            } catch (NoSuchElementException ignored) {
+               // this could happen through paging browsing
             }
+
             CompositeData[] rc = new CompositeData[c.size()];
             c.toArray(rc);
             return rc;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f1249e39/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java
index 4590c0b..bf0ed0b 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java
@@ -25,6 +25,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.NoSuchElementException;
 import java.util.Set;
 import java.util.TreeSet;
 
@@ -210,8 +211,9 @@ public class ScaleDownHandler {
                   for (QueuesXRefInnerManager queueFound : queuesFound) {
                      ackMessageOnQueue(tx, queueFound.getQueue(), messageReference);
                   }
-
                }
+            } catch (NoSuchElementException ignored) {
+               // this could happen through paging browsing
             }
          }
 
@@ -294,6 +296,8 @@ public class ScaleDownHandler {
 
                ackMessageOnQueue(tx, queue, messageRef);
             }
+         } catch (NoSuchElementException ignored) {
+            // this could happen through paging browsing
          }
       }
 


Mime
View raw message