avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1527057 - in /avro/trunk: CHANGES.txt lang/java/avro/src/main/java/org/apache/avro/Schema.java lang/java/ipc/src/test/java/org/apache/avro/TestSchema.java
Date Fri, 27 Sep 2013 20:12:55 GMT
Author: cutting
Date: Fri Sep 27 20:12:55 2013
New Revision: 1527057

URL: http://svn.apache.org/r1527057
Log:
AVRO-1377. Java: Fix a bug in Schema#toString() when a namespaced enum or fixed is defined
within an un-namespaced record.  Contributed by Graham Sanderson.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/Schema.java
    avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestSchema.java

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1527057&r1=1527056&r2=1527057&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Fri Sep 27 20:12:55 2013
@@ -23,6 +23,10 @@ Trunk (not yet released)
     AVRO-1366. Fix specification's description of metadata format.
     (cutting)
 
+    AVRO-1377. Java: Fix a bug in Schema#toString() when a namespaced
+    enum or fixed is defined within an un-namespaced record.
+    (Graham Sanderson via cutting)
+
 Avro 1.7.5 (12 August 2013)
 
   NEW FEATURES

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/Schema.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/Schema.java?rev=1527057&r1=1527056&r2=1527057&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/Schema.java (original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/Schema.java Fri Sep 27 20:12:55
2013
@@ -458,8 +458,6 @@ public abstract class Schema extends Jso
       if (space != null) {
         if (!space.equals(names.space()))
           gen.writeStringField("namespace", space);
-        if (names.space() == null)                // default namespace
-          names.space(space);
       } else if (names.space() != null) {         // null within non-null
         gen.writeStringField("namespace", "");
       }

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestSchema.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestSchema.java?rev=1527057&r1=1527056&r2=1527057&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestSchema.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestSchema.java Fri Sep 27 20:12:55
2013
@@ -481,6 +481,28 @@ public class TestSchema {
   }
 
   @Test
+  public void testNestedNonNullNamespace1() throws Exception {
+    Schema inner1 = Schema.createEnum("InnerEnum", null, "space", Arrays.asList("x"));
+    Schema inner2 = Schema.parse("{\"type\":\"record\",\"namespace\":\"space\",\"name\":"
+      +"\"InnerRecord\",\"fields\":[]}");
+    Schema nullOuter = Schema.createRecord("Outer", null, null, false);
+    nullOuter.setFields(Arrays.asList(new Field("f1", inner1, null, null),
+                                      new Field("f2", inner2, null, null)));
+    assertEquals(nullOuter, Schema.parse(nullOuter.toString()));
+  }
+
+  @Test
+  public void testNestedNonNullNamespace2() throws Exception {
+    Schema inner1 = Schema.createFixed("InnerFixed", null, "space", 1);
+    Schema inner2 = Schema.parse("{\"type\":\"record\",\"namespace\":\"space\",\"name\":"
+      +"\"InnerRecord\",\"fields\":[]}");
+    Schema nullOuter = Schema.createRecord("Outer", null, null, false);
+    nullOuter.setFields(Arrays.asList(new Field("f1", inner1, null, null),
+                                      new Field("f2", inner2, null, null)));
+    assertEquals(nullOuter, Schema.parse(nullOuter.toString()));
+  }
+
+  @Test
   public void testNullPointer() throws Exception {
     String recordJson = "{\"type\":\"record\", \"name\":\"Test\", \"fields\":"
       +"[{\"name\":\"x\", \"type\":\"string\"}]}";



Mime
View raw message