You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ju...@apache.org on 2016/02/26 02:53:24 UTC

kafka git commit: KAFKA-3292; ClientQuotaManager.getOrCreateQuotaSensors() may return a null ClientSensors.throttleTimeSensor

Repository: kafka
Updated Branches:
  refs/heads/trunk b3b533171 -> af1699bcc


KAFKA-3292; ClientQuotaManager.getOrCreateQuotaSensors() may return a null ClientSensors.throttleTimeSensor

Author: Ismael Juma <is...@juma.me.uk>

Reviewers: Jun Rao <ju...@gmail.com>

Closes #977 from ijuma/kafka-3292-null-throttle-time-sensor


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

Branch: refs/heads/trunk
Commit: af1699bccbb725633f0b9deb666054a573da7667
Parents: b3b5331
Author: Ismael Juma <is...@juma.me.uk>
Authored: Thu Feb 25 17:53:19 2016 -0800
Committer: Jun Rao <ju...@gmail.com>
Committed: Thu Feb 25 17:53:19 2016 -0800

----------------------------------------------------------------------
 core/src/main/scala/kafka/server/ClientQuotaManager.scala | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/af1699bc/core/src/main/scala/kafka/server/ClientQuotaManager.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/server/ClientQuotaManager.scala b/core/src/main/scala/kafka/server/ClientQuotaManager.scala
index 37b432c..5ec57ce 100644
--- a/core/src/main/scala/kafka/server/ClientQuotaManager.scala
+++ b/core/src/main/scala/kafka/server/ClientQuotaManager.scala
@@ -200,7 +200,10 @@ class ClientQuotaManager(private val config: ClientQuotaManagerConfig,
        */
       lock.writeLock().lock()
       try {
+        // Set the var for both sensors in case another thread has won the race to acquire the write lock. This will
+        // ensure that we initialise `ClientSensors` with non-null parameters.
         quotaSensor = metrics.getSensor(quotaSensorName)
+        throttleTimeSensor = metrics.getSensor(throttleTimeSensorName)
         if (quotaSensor == null) {
           // create the throttle time sensor also. Use default metric config
           throttleTimeSensor = metrics.sensor(throttleTimeSensorName,