From 1814e7c904072f0f67c5128d53a20d26ebb56b1a Mon Sep 17 00:00:00 2001 From: Jun Rao Date: Tue, 12 May 2015 15:37:21 -0700 Subject: [PATCH] synchronize on getting size from watchers --- core/src/main/scala/kafka/server/RequestPurgatory.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/main/scala/kafka/server/RequestPurgatory.scala b/core/src/main/scala/kafka/server/RequestPurgatory.scala index 87ee3be..098679c 100644 --- a/core/src/main/scala/kafka/server/RequestPurgatory.scala +++ b/core/src/main/scala/kafka/server/RequestPurgatory.scala @@ -196,7 +196,11 @@ abstract class RequestPurgatory[T <: DelayedRequest](brokerId: Int = 0, purgeInt private val requests = new util.LinkedList[T] // return the size of the watch list - def watched() = requests.size() + def watched() = { + synchronized { + requests.size() + } + } // add the element to the watcher list if it's not already satisfied def addIfNotSatisfied(t: T): Boolean = { -- 1.8.5.2 (Apple Git-48)