mirror of https://github.com/apache/activemq.git
fix current modification of linked list
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@634415 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c0b74f0562
commit
d56371fd69
|
@ -211,7 +211,7 @@ public interface PendingMessageCursor extends Service {
|
|||
* @param maxItems
|
||||
* @return a list of paged in messages
|
||||
*/
|
||||
LinkedList pageInList(int maxItems);
|
||||
LinkedList<MessageReference> pageInList(int maxItems);
|
||||
|
||||
/**
|
||||
* set the maximum number of producers to track at one time
|
||||
|
|
|
@ -35,7 +35,7 @@ public class VMPendingMessageCursor extends AbstractPendingMessageCursor {
|
|||
/**
|
||||
* @return true if there are no pending messages
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
public synchronized boolean isEmpty() {
|
||||
if (list.isEmpty()) {
|
||||
return true;
|
||||
} else {
|
||||
|
@ -57,7 +57,7 @@ public class VMPendingMessageCursor extends AbstractPendingMessageCursor {
|
|||
/**
|
||||
* reset the cursor
|
||||
*/
|
||||
public void reset() {
|
||||
public synchronized void reset() {
|
||||
iter = list.listIterator();
|
||||
last = null;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class VMPendingMessageCursor extends AbstractPendingMessageCursor {
|
|||
*
|
||||
* @param node
|
||||
*/
|
||||
public void addMessageLast(MessageReference node) {
|
||||
public synchronized void addMessageLast(MessageReference node) {
|
||||
node.incrementReferenceCount();
|
||||
list.addLast(node);
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public class VMPendingMessageCursor extends AbstractPendingMessageCursor {
|
|||
* @param position
|
||||
* @param node
|
||||
*/
|
||||
public void addMessageFirst(MessageReference node) {
|
||||
public synchronized void addMessageFirst(MessageReference node) {
|
||||
node.incrementReferenceCount();
|
||||
list.addFirst(node);
|
||||
}
|
||||
|
@ -86,14 +86,14 @@ public class VMPendingMessageCursor extends AbstractPendingMessageCursor {
|
|||
/**
|
||||
* @return true if there pending messages to dispatch
|
||||
*/
|
||||
public boolean hasNext() {
|
||||
public synchronized boolean hasNext() {
|
||||
return iter.hasNext();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the next pending message
|
||||
*/
|
||||
public MessageReference next() {
|
||||
public synchronized MessageReference next() {
|
||||
last = (MessageReference)iter.next();
|
||||
return last;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public class VMPendingMessageCursor extends AbstractPendingMessageCursor {
|
|||
/**
|
||||
* remove the message at the cursor position
|
||||
*/
|
||||
public void remove() {
|
||||
public synchronized void remove() {
|
||||
if (last != null) {
|
||||
last.decrementReferenceCount();
|
||||
}
|
||||
|
@ -111,18 +111,18 @@ public class VMPendingMessageCursor extends AbstractPendingMessageCursor {
|
|||
/**
|
||||
* @return the number of pending messages
|
||||
*/
|
||||
public int size() {
|
||||
public synchronized int size() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* clear all pending messages
|
||||
*/
|
||||
public void clear() {
|
||||
public synchronized void clear() {
|
||||
list.clear();
|
||||
}
|
||||
|
||||
public void remove(MessageReference node) {
|
||||
public synchronized void remove(MessageReference node) {
|
||||
for (Iterator<MessageReference> i = list.iterator(); i.hasNext();) {
|
||||
MessageReference ref = i.next();
|
||||
if (node.getMessageId().equals(ref.getMessageId())) {
|
||||
|
|
Loading…
Reference in New Issue