mirror of https://github.com/apache/activemq.git
fixed a potential hole around lock usage
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@961272 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
28180b35bd
commit
720ff40ac0
|
@ -1677,23 +1677,19 @@ public class Queue extends BaseDestination implements Task, UsageListener {
|
|||
}
|
||||
// Only add new messages, not already pagedIn to avoid multiple
|
||||
// dispatch attempts
|
||||
pagedInMessagesLock.readLock().lock();
|
||||
pagedInMessagesLock.writeLock().lock();
|
||||
try {
|
||||
resultList = new ArrayList<QueueMessageReference>(result.size());
|
||||
for (QueueMessageReference ref : result) {
|
||||
if (!pagedInMessages.containsKey(ref.getMessageId())) {
|
||||
pagedInMessagesLock.readLock().unlock();
|
||||
pagedInMessagesLock.writeLock().lock();
|
||||
if (!pagedInMessages.containsKey(ref.getMessageId())) {
|
||||
pagedInMessages.put(ref.getMessageId(), ref);
|
||||
pagedInMessagesLock.readLock().lock();
|
||||
pagedInMessagesLock.writeLock().unlock();
|
||||
resultList.add(ref);
|
||||
} else {
|
||||
ref.decrementReferenceCount();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
pagedInMessagesLock.readLock().unlock();
|
||||
pagedInMessagesLock.writeLock().unlock();
|
||||
}
|
||||
} else {
|
||||
// Avoid return null list, if condition is not validated
|
||||
|
|
Loading…
Reference in New Issue