AMQ-7129 - code cleanup

(cherry picked from commit a16b227808)
This commit is contained in:
Christopher L. Shannon (cshannon) 2019-01-11 10:31:44 -05:00
parent 0b88dabb40
commit 5acd9303a5
1 changed files with 14 additions and 16 deletions

View File

@ -3010,24 +3010,22 @@ public abstract class MessageDatabase extends ServiceSupport implements BrokerSe
//grab the messages attached to this subscription //grab the messages attached to this subscription
SequenceSet messageSequences = sd.ackPositions.get(tx, subscriptionKey); SequenceSet messageSequences = sd.ackPositions.get(tx, subscriptionKey);
if (messageSequences != null) { if (messageSequences != null && !messageSequences.isEmpty()) {
if (!messageSequences.isEmpty()) { final Sequence head = messageSequences.getHead();
final Sequence head = messageSequences.getHead();
//get an iterator over the order index starting at the first unacked message //get an iterator over the order index starting at the first unacked message
//and go over each message to add up the size //and go over each message to add up the size
Iterator<Entry<Long, MessageKeys>> iterator = sd.orderIndex.iterator(tx, Iterator<Entry<Long, MessageKeys>> iterator = sd.orderIndex.iterator(tx,
new MessageOrderCursor(head.getFirst())); new MessageOrderCursor(head.getFirst()));
final boolean contiguousRange = messageSequences.size() == 1; final boolean contiguousRange = messageSequences.size() == 1;
while (iterator.hasNext()) { while (iterator.hasNext()) {
Entry<Long, MessageKeys> entry = iterator.next(); Entry<Long, MessageKeys> entry = iterator.next();
//Verify sequence contains the key //Verify sequence contains the key
//if contiguous we just add all starting with the first but if not //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 //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())) { if (contiguousRange || messageSequences.contains(entry.getKey())) {
locationSize += entry.getValue().location.getSize(); locationSize += entry.getValue().location.getSize();
}
} }
} }
} }