ARTEMIS-1029 Cleaning up small possible Exception
treating an exception after the PagingIterator in case of duplicates cleanups
This commit is contained in:
parent
526b42a428
commit
f1249e39a9
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue