Repository: kafka
Updated Branches:
  refs/heads/trunk 2490b1c49 -> 26673f982


kafka-2112; make overflowWheel volatile; patched by Yasuhiro Matsuda; reviewed 
by Jun Rao


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/26673f98
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/26673f98
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/26673f98

Branch: refs/heads/trunk
Commit: 26673f982e7da885cdb8f615cc7868237106de64
Parents: 2490b1c
Author: Yasuhiro Matsuda <[email protected]>
Authored: Thu Apr 9 12:15:25 2015 -0700
Committer: Jun Rao <[email protected]>
Committed: Thu Apr 9 12:15:25 2015 -0700

----------------------------------------------------------------------
 core/src/main/scala/kafka/utils/timer/TimingWheel.scala | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/26673f98/core/src/main/scala/kafka/utils/timer/TimingWheel.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/utils/timer/TimingWheel.scala 
b/core/src/main/scala/kafka/utils/timer/TimingWheel.scala
index 9a36c20..e92aba3 100644
--- a/core/src/main/scala/kafka/utils/timer/TimingWheel.scala
+++ b/core/src/main/scala/kafka/utils/timer/TimingWheel.scala
@@ -103,7 +103,10 @@ private[timer] class TimingWheel(tickMs: Long, wheelSize: 
Int, startMs: Long, ta
   private[this] val buckets = Array.tabulate[TimerTaskList](wheelSize) { _ => 
new TimerTaskList(taskCounter) }
 
   private[this] var currentTime = startMs - (startMs % tickMs) // rounding 
down to multiple of tickMs
-  private[this] var overflowWheel: TimingWheel = null
+
+  // overflowWheel can potentially be updated and read by two concurrent 
threads through add().
+  // Therefore, it needs to be volatile due to the issue of Double-Checked 
Locking pattern with JVM
+  @volatile private[this] var overflowWheel: TimingWheel = null
 
   private[this] def addOverflowWheel(): Unit = {
     synchronized {

Reply via email to