kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gwens...@apache.org
Subject kafka git commit: KAFKA-2973; Fix leak of child sensors on remove
Date Wed, 09 Dec 2015 17:52:21 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 991aad23b -> 977ebbe9b


KAFKA-2973; Fix leak of child sensors on remove

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

Reviewers: Gwen Shapira, Guozhang Wang

Closes #650 from ijuma/kafka-2973-fix-leak-child-sensors-on-remove


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

Branch: refs/heads/trunk
Commit: 977ebbe9bafb6c1a6e1be69620f745712118fe80
Parents: 991aad2
Author: Ismael Juma <ismael@juma.me.uk>
Authored: Wed Dec 9 09:52:17 2015 -0800
Committer: Gwen Shapira <cshapi@gmail.com>
Committed: Wed Dec 9 09:52:17 2015 -0800

----------------------------------------------------------------------
 .../src/main/java/org/apache/kafka/common/metrics/Metrics.java    | 2 +-
 .../test/java/org/apache/kafka/common/metrics/MetricsTest.java    | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/977ebbe9/clients/src/main/java/org/apache/kafka/common/metrics/Metrics.java
----------------------------------------------------------------------
diff --git a/clients/src/main/java/org/apache/kafka/common/metrics/Metrics.java b/clients/src/main/java/org/apache/kafka/common/metrics/Metrics.java
index 842e0f7..afca2e5 100644
--- a/clients/src/main/java/org/apache/kafka/common/metrics/Metrics.java
+++ b/clients/src/main/java/org/apache/kafka/common/metrics/Metrics.java
@@ -285,7 +285,7 @@ public class Metrics implements Closeable {
             this.sensors.put(name, s);
             if (parents != null) {
                 for (Sensor parent : parents) {
-                    List<Sensor> children = childrenSensors.get(parent.name());
+                    List<Sensor> children = childrenSensors.get(parent);
                     if (children == null) {
                         children = new ArrayList<>();
                         childrenSensors.put(parent, children);

http://git-wip-us.apache.org/repos/asf/kafka/blob/977ebbe9/clients/src/test/java/org/apache/kafka/common/metrics/MetricsTest.java
----------------------------------------------------------------------
diff --git a/clients/src/test/java/org/apache/kafka/common/metrics/MetricsTest.java b/clients/src/test/java/org/apache/kafka/common/metrics/MetricsTest.java
index d7723ae..f5b49ba 100644
--- a/clients/src/test/java/org/apache/kafka/common/metrics/MetricsTest.java
+++ b/clients/src/test/java/org/apache/kafka/common/metrics/MetricsTest.java
@@ -155,6 +155,9 @@ public class MetricsTest {
         assertEquals(1.0, c2, EPS);
         assertEquals(1.0 + c1, p2, EPS);
         assertEquals(1.0 + c1 + c2, p1, EPS);
+        assertEquals(Arrays.asList(child1, child2), metrics.childrenSensors().get(parent1));
+        assertEquals(Arrays.asList(child1), metrics.childrenSensors().get(parent2));
+        assertNull(metrics.childrenSensors().get(grandchild));
     }
 
     @Test(expected = IllegalArgumentException.class)


Mime
View raw message