kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From guozh...@apache.org
Subject kafka git commit: MINOR: fix Quota's equal() function
Date Tue, 29 Sep 2015 17:50:55 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 2c4e63a89 -> 73720113b


MINOR: fix Quota's equal() function

It compares upper bound with itself.

Author: Edward Ribeiro <edward.ribeiro@gmail.com>

Reviewers: Aditya Auradkar, Ismael Juma, Guozhang Wang

Closes #182 from eribeiro/equals-bug


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

Branch: refs/heads/trunk
Commit: 73720113b97ccfcd796a844f87438546ed2e09e4
Parents: 2c4e63a
Author: Edward Ribeiro <edward.ribeiro@gmail.com>
Authored: Tue Sep 29 10:54:45 2015 -0700
Committer: Guozhang Wang <wangguoz@gmail.com>
Committed: Tue Sep 29 10:54:45 2015 -0700

----------------------------------------------------------------------
 .../java/org/apache/kafka/common/metrics/Quota.java |  2 +-
 .../apache/kafka/common/metrics/MetricsTest.java    | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/73720113/clients/src/main/java/org/apache/kafka/common/metrics/Quota.java
----------------------------------------------------------------------
diff --git a/clients/src/main/java/org/apache/kafka/common/metrics/Quota.java b/clients/src/main/java/org/apache/kafka/common/metrics/Quota.java
index a3535dc..235b599 100644
--- a/clients/src/main/java/org/apache/kafka/common/metrics/Quota.java
+++ b/clients/src/main/java/org/apache/kafka/common/metrics/Quota.java
@@ -65,6 +65,6 @@ public final class Quota {
         if (!(obj instanceof Quota))
             return false;
         Quota that = (Quota) obj;
-        return (that.bound == this.bound) && (this.upper == this.upper);
+        return (that.bound == this.bound) && (that.upper == this.upper);
     }
 }

http://git-wip-us.apache.org/repos/asf/kafka/blob/73720113/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 9096ef7..f1eba18 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
@@ -35,6 +35,10 @@ import org.apache.kafka.common.metrics.stats.Rate;
 import org.apache.kafka.common.metrics.stats.Total;
 import org.apache.kafka.common.utils.MockTime;
 import org.junit.Test;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 public class MetricsTest {
 
@@ -275,6 +279,18 @@ public class MetricsTest {
     }
 
     @Test
+    public void testQuotasEquality() {
+        final Quota quota1 = Quota.lessThan(10.5);
+        final Quota quota2 = Quota.moreThan(10.5);
+
+        assertFalse("Quota with different upper values shouldn't be equal", quota1.equals(quota2));
+
+        final Quota quota3 = Quota.moreThan(10.5);
+
+        assertTrue("Quota with same upper and bound values should be equal", quota2.equals(quota3));
+    }
+
+    @Test
     public void testPercentiles() {
         int buckets = 100;
         Percentiles percs = new Percentiles(4 * buckets,


Mime
View raw message