kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ewe...@apache.org
Subject kafka git commit: KAFKA-5579: check for null
Date Mon, 17 Jul 2017 17:45:53 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk cf94b188f -> 6d7a81b47


KAFKA-5579: check for null

Author: Jeremy Custenborder <jcustenborder@gmail.com>

Reviewers: Randall Hauch <rhauch@gmail.com>, Ewen Cheslack-Postava <ewen@confluent.io>

Closes #3517 from jcustenborder/KAFKA-5579


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

Branch: refs/heads/trunk
Commit: 6d7a81b478e1f36d7632c84d34280c22a2f717b1
Parents: cf94b18
Author: Jeremy Custenborder <jcustenborder@gmail.com>
Authored: Mon Jul 17 10:45:31 2017 -0700
Committer: Ewen Cheslack-Postava <me@ewencp.org>
Committed: Mon Jul 17 10:45:31 2017 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/kafka/connect/data/SchemaBuilder.java  | 2 ++
 .../java/org/apache/kafka/connect/data/SchemaBuilderTest.java   | 5 +++++
 2 files changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/6d7a81b4/connect/api/src/main/java/org/apache/kafka/connect/data/SchemaBuilder.java
----------------------------------------------------------------------
diff --git a/connect/api/src/main/java/org/apache/kafka/connect/data/SchemaBuilder.java b/connect/api/src/main/java/org/apache/kafka/connect/data/SchemaBuilder.java
index e0109bb..a9064b8 100644
--- a/connect/api/src/main/java/org/apache/kafka/connect/data/SchemaBuilder.java
+++ b/connect/api/src/main/java/org/apache/kafka/connect/data/SchemaBuilder.java
@@ -76,6 +76,8 @@ public class SchemaBuilder implements Schema {
     private Map<String, String> parameters;
 
     public SchemaBuilder(Type type) {
+        if (null == type)
+            throw new SchemaBuilderException("type cannot be null");
         this.type = type;
         if (type == Type.STRUCT) {
             fields = new LinkedHashMap<>();

http://git-wip-us.apache.org/repos/asf/kafka/blob/6d7a81b4/connect/api/src/test/java/org/apache/kafka/connect/data/SchemaBuilderTest.java
----------------------------------------------------------------------
diff --git a/connect/api/src/test/java/org/apache/kafka/connect/data/SchemaBuilderTest.java
b/connect/api/src/test/java/org/apache/kafka/connect/data/SchemaBuilderTest.java
index 886a5e7..b40e654 100644
--- a/connect/api/src/test/java/org/apache/kafka/connect/data/SchemaBuilderTest.java
+++ b/connect/api/src/test/java/org/apache/kafka/connect/data/SchemaBuilderTest.java
@@ -355,6 +355,11 @@ public class SchemaBuilderTest {
             .build();
     }
 
+    @Test(expected = SchemaBuilderException.class)
+    public void testTypeNotNull() {
+        SchemaBuilder.type(null);
+    }
+
     private void assertTypeAndDefault(Schema schema, Schema.Type type, boolean optional,
Object defaultValue) {
         assertEquals(type, schema.type());
         assertEquals(optional, schema.isOptional());


Mime
View raw message