kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ij...@apache.org
Subject kafka git commit: MINOR: Handle null values in validators
Date Wed, 04 May 2016 01:27:40 GMT
Repository: kafka
Updated Branches:
  refs/heads/0.10.0 2d9369663 -> 41a8cb252


MINOR: Handle null values in validators

Author: Ewen Cheslack-Postava <me@ewencp.org>

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

Closes #1316 from ewencp/minor-handle-null-values-validators

(cherry picked from commit 03a1f7d39c553835022987826df4762cfd39a639)
Signed-off-by: Ismael Juma <ismael@juma.me.uk>


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

Branch: refs/heads/0.10.0
Commit: 41a8cb2520066b138ca2d9bbccb1dbdfdf577aa6
Parents: 2d93696
Author: Ewen Cheslack-Postava <me@ewencp.org>
Authored: Wed May 4 02:14:35 2016 +0100
Committer: Ismael Juma <ismael@juma.me.uk>
Committed: Wed May 4 02:27:16 2016 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/kafka/common/config/ConfigDef.java  | 2 ++
 .../test/java/org/apache/kafka/common/config/ConfigDefTest.java  | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/41a8cb25/clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java
----------------------------------------------------------------------
diff --git a/clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java b/clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java
index 3a562ce..256f523 100644
--- a/clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java
+++ b/clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java
@@ -790,6 +790,8 @@ public class ConfigDef {
         }
 
         public void ensureValid(String name, Object o) {
+            if (o == null)
+                throw new ConfigException(name, o, "Value must be non-null");
             Number n = (Number) o;
             if (min != null && n.doubleValue() < min.doubleValue())
                 throw new ConfigException(name, o, "Value must be at least " + min);

http://git-wip-us.apache.org/repos/asf/kafka/blob/41a8cb25/clients/src/test/java/org/apache/kafka/common/config/ConfigDefTest.java
----------------------------------------------------------------------
diff --git a/clients/src/test/java/org/apache/kafka/common/config/ConfigDefTest.java b/clients/src/test/java/org/apache/kafka/common/config/ConfigDefTest.java
index e20e422..0ed0f1a 100644
--- a/clients/src/test/java/org/apache/kafka/common/config/ConfigDefTest.java
+++ b/clients/src/test/java/org/apache/kafka/common/config/ConfigDefTest.java
@@ -132,9 +132,9 @@ public class ConfigDefTest {
 
     @Test
     public void testValidators() {
-        testValidators(Type.INT, Range.between(0, 10), 5, new Object[]{1, 5, 9}, new Object[]{-1,
11});
+        testValidators(Type.INT, Range.between(0, 10), 5, new Object[]{1, 5, 9}, new Object[]{-1,
11, null});
         testValidators(Type.STRING, ValidString.in("good", "values", "default"), "default",
-                new Object[]{"good", "values", "default"}, new Object[]{"bad", "inputs"});
+                new Object[]{"good", "values", "default"}, new Object[]{"bad", "inputs",
null});
     }
 
     @Test


Mime
View raw message