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:03:04 GMT
Repository: avro
Updated Branches:
  refs/heads/master a3e05bee1 -> a7a43da6d


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/a7a43da6
Tree: http://git-wip-us.apache.org/repos/asf/avro/tree/a7a43da6
Diff: http://git-wip-us.apache.org/repos/asf/avro/diff/a7a43da6

Branch: refs/heads/master
Commit: a7a43da6de9bd44e57e057319127c64b2fca56a0
Parents: a3e05be
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 10:57:06 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/a7a43da6/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 118ab09..04c4923 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -220,6 +220,8 @@ Trunk (not yet released)
     AVRO-1485: Specification says Record field type can be record name but implementation
allows any named type.
     (Nandor Kollar via gabor)
 
+    AVRO-2120: Fix NullPointerException thrown by Schema.Parser#parse("")
+
 Avro 1.8.1 (14 May 2016)
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/avro/blob/a7a43da6/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 ca9529a..97aed83 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
@@ -1225,6 +1225,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/a7a43da6/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 d89882f..25858b5 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<>();


Mime
View raw message