AMQ-6947 - Make sure counters are updated correct on message drop

Only update metrics counters when message is removed from the
pagedInMessages list which is important to check in case of duplicates

(cherry picked from commit 021c82859c)
This commit is contained in:
Christopher L. Shannon (cshannon) 2018-04-17 08:23:59 -04:00
parent 0036084af6
commit 1fe096cb2a
1 changed files with 4 additions and 3 deletions

View File

@ -1839,11 +1839,12 @@ public class Queue extends BaseDestination implements Task, UsageListener, Index
private void dropMessage(QueueMessageReference reference) {
//use dropIfLive so we only process the statistics at most one time
if (reference.dropIfLive()) {
getDestinationStatistics().getDequeues().increment();
getDestinationStatistics().getMessages().decrement();
pagedInMessagesLock.writeLock().lock();
try {
pagedInMessages.remove(reference);
if (pagedInMessages.remove(reference) != null) {
getDestinationStatistics().getDequeues().increment();
getDestinationStatistics().getMessages().decrement();
}
} finally {
pagedInMessagesLock.writeLock().unlock();
}