From 3d18d5990422d8e92eb1e71cd3348f6131b8456c Mon Sep 17 00:00:00 2001 From: "Hiram R. Chirino" Date: Mon, 3 Mar 2008 18:03:21 +0000 Subject: [PATCH] Protect the messagesWaitingForSpace variable against concurrent modification. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@633210 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/activemq/broker/region/Queue.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java b/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java index 5b7df0d0c3..b3c6659587 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java @@ -885,9 +885,12 @@ public class Queue extends BaseDestination implements Task { log.error("Failed to page in more queue messages ", e); } } - while (!messagesWaitingForSpace.isEmpty() && !memoryUsage.isFull()) { - Runnable op = messagesWaitingForSpace.removeFirst(); - op.run(); + + synchronized(messagesWaitingForSpace) { + while (!messagesWaitingForSpace.isEmpty() && !memoryUsage.isFull()) { + Runnable op = messagesWaitingForSpace.removeFirst(); + op.run(); + } } return false; }