avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nielsbas...@apache.org
Subject avro git commit: AVRO-2120: Fix NullPointerException thrown by Schema.Parser#parse("")
Date Tue, 02 Jan 2018 10:09:34 GMT
Repository: avro
Updated Branches:
  refs/heads/branch-1.8 e39170ef8 -> 9754e0489


AVRO-2120: Fix NullPointerException thrown by Schema.Parser#parse("")


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

Branch: refs/heads/branch-1.8
Commit: 9754e0489093f295402fb370018caaa422d4a2ed
Parents: e39170e
Author: Niels Basjes <nbasjes@bol.com>
Authored: Sat Dec 23 13:24:52 2017 +0100
Committer: Niels Basjes <nbasjes@bol.com>
Committed: Tue Jan 2 11:05:00 2018 +0100

----------------------------------------------------------------------
 CHANGES.txt                                                  | 2 ++
 lang/java/avro/src/main/java/org/apache/avro/Schema.java     | 3 +++
 lang/java/avro/src/test/java/org/apache/avro/TestSchema.java | 5 +++++
 3 files changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/avro/blob/9754e048/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 75c08ac..3f62cb9 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -33,6 +33,8 @@ Trunk (not yet released)
     AVRO-1967: Java: Fix NPE when calling getXyzBuilder on instance where the xyz is null
     (Niels Basjes)
 
+    AVRO-2120: Fix NullPointerException thrown by Schema.Parser#parse("")
+
 Avro 1.8.2 (10 April 2017)
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/avro/blob/9754e048/lang/java/avro/src/main/java/org/apache/avro/Schema.java
----------------------------------------------------------------------
diff --git a/lang/java/avro/src/main/java/org/apache/avro/Schema.java b/lang/java/avro/src/main/java/org/apache/avro/Schema.java
index 2238c27..1053328 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/Schema.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/Schema.java
@@ -1222,6 +1222,9 @@ public abstract class Schema extends JsonProperties {
 
   /** @see #parse(String) */
   static Schema parse(JsonNode schema, Names names) {
+    if (schema == null) {
+      throw new SchemaParseException("Cannot parse <null> schema");
+    }
     if (schema.isTextual()) {                     // name
       Schema result = names.get(schema.getTextValue());
       if (result == null)

http://git-wip-us.apache.org/repos/asf/avro/blob/9754e048/lang/java/avro/src/test/java/org/apache/avro/TestSchema.java
----------------------------------------------------------------------
diff --git a/lang/java/avro/src/test/java/org/apache/avro/TestSchema.java b/lang/java/avro/src/test/java/org/apache/avro/TestSchema.java
index 242ee8c..a2a06db 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/TestSchema.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/TestSchema.java
@@ -83,6 +83,11 @@ public class TestSchema {
     assertNotNull(schemaString);
   }
 
+  @Test(expected = SchemaParseException.class)
+  public void testParseEmptySchema() {
+    Schema schema = new Schema.Parser().parse("");
+  }
+
   @Test
   public void testSchemaWithFields() {
     List<Field> fields = new ArrayList<Field>();


Mime
View raw message