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
|
// Only add new messages, not already pagedIn to avoid multiple
|
||||||
// dispatch attempts
|
// dispatch attempts
|
||||||
pagedInMessagesLock.readLock().lock();
|
pagedInMessagesLock.writeLock().lock();
|
||||||
try {
|
try {
|
||||||
resultList = new ArrayList<QueueMessageReference>(result.size());
|
resultList = new ArrayList<QueueMessageReference>(result.size());
|
||||||
for (QueueMessageReference ref : result) {
|
for (QueueMessageReference ref : result) {
|
||||||
if (!pagedInMessages.containsKey(ref.getMessageId())) {
|
if (!pagedInMessages.containsKey(ref.getMessageId())) {
|
||||||
pagedInMessagesLock.readLock().unlock();
|
|
||||||
pagedInMessagesLock.writeLock().lock();
|
|
||||||
pagedInMessages.put(ref.getMessageId(), ref);
|
pagedInMessages.put(ref.getMessageId(), ref);
|
||||||
pagedInMessagesLock.readLock().lock();
|
|
||||||
pagedInMessagesLock.writeLock().unlock();
|
|
||||||
resultList.add(ref);
|
resultList.add(ref);
|
||||||
} else {
|
} else {
|
||||||
ref.decrementReferenceCount();
|
ref.decrementReferenceCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
pagedInMessagesLock.readLock().unlock();
|
pagedInMessagesLock.writeLock().unlock();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Avoid return null list, if condition is not validated
|
// Avoid return null list, if condition is not validated
|
||||||
|
|
Loading…
Reference in New Issue