From 5acd9303a53cd11f5109bfa96591d8d6dbf853bc Mon Sep 17 00:00:00 2001 From: "Christopher L. Shannon (cshannon)" Date: Fri, 11 Jan 2019 10:31:44 -0500 Subject: [PATCH] AMQ-7129 - code cleanup (cherry picked from commit a16b227808bec2977f1d3323bf29257b3c8ca9f6) --- .../store/kahadb/MessageDatabase.java | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java index 8030bc47ff..83650e84ec 100644 --- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java +++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java @@ -3010,24 +3010,22 @@ public abstract class MessageDatabase extends ServiceSupport implements BrokerSe //grab the messages attached to this subscription SequenceSet messageSequences = sd.ackPositions.get(tx, subscriptionKey); - if (messageSequences != null) { - if (!messageSequences.isEmpty()) { - final Sequence head = messageSequences.getHead(); + if (messageSequences != null && !messageSequences.isEmpty()) { + final Sequence head = messageSequences.getHead(); - //get an iterator over the order index starting at the first unacked message - //and go over each message to add up the size - Iterator> iterator = sd.orderIndex.iterator(tx, - new MessageOrderCursor(head.getFirst())); + //get an iterator over the order index starting at the first unacked message + //and go over each message to add up the size + Iterator> iterator = sd.orderIndex.iterator(tx, + new MessageOrderCursor(head.getFirst())); - final boolean contiguousRange = messageSequences.size() == 1; - while (iterator.hasNext()) { - Entry entry = iterator.next(); - //Verify sequence contains the key - //if contiguous we just add all starting with the first but if not - //we need to check if the id is part of the range - could happen if individual ack mode was used - if (contiguousRange || messageSequences.contains(entry.getKey())) { - locationSize += entry.getValue().location.getSize(); - } + final boolean contiguousRange = messageSequences.size() == 1; + while (iterator.hasNext()) { + Entry entry = iterator.next(); + //Verify sequence contains the key + //if contiguous we just add all starting with the first but if not + //we need to check if the id is part of the range - could happen if individual ack mode was used + if (contiguousRange || messageSequences.contains(entry.getKey())) { + locationSize += entry.getValue().location.getSize(); } } }