avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1468677 - 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 Tue, 16 Apr 2013 23:25:56 GMT
Author: cutting
Date: Tue Apr 16 23:25:56 2013
New Revision: 1468677

URL: http://svn.apache.org/r1468677
Log:
AVRO-1295. Java: Fix printing of a non-null namespace within a null namespace.

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=1468677&r1=1468676&r2=1468677&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Tue Apr 16 23:25:56 2013
@@ -33,6 +33,9 @@ Trunk (not yet released)
     AVRO-1266. Java: Fix mapred.AvroMultipleOutputs to support multiple
     different schemas.  (Ashish Nagavaram via martinkl)
 
+    AVRO-1295. Java: Fix printing of a non-null namespace within a
+    null namespace. (cutting)
+
 Avro 1.7.4 (22 February 2012)
 
   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=1468677&r1=1468676&r2=1468677&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 Tue Apr 16 23:25:56
2013
@@ -426,6 +426,8 @@ public abstract class Schema extends Jso
         return;
       }
       int lastDot = name.lastIndexOf('.');
+      if ("".equals(space))
+        space = null;
       if (lastDot < 0) {                          // unqualified name
         this.space = space;                       // use default space
         this.name = validateName(name);
@@ -452,6 +454,8 @@ public abstract class Schema extends Jso
           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", "");
       }
     }
     public String getQualified(String defaultSpace) {

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=1468677&r1=1468676&r2=1468677&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 Tue Apr 16 23:25:56
2013
@@ -472,6 +472,15 @@ public class TestSchema {
   }
 
   @Test
+  public void testNestedNullNamespace() throws Exception {
+    Schema inner =
+      Schema.parse("{\"type\":\"record\",\"name\":\"Inner\",\"fields\":[]}");
+    Schema outer = Schema.createRecord("Outer", null, "space", false);
+    outer.setFields(Arrays.asList(new Field("f", inner, null, null)));
+    assertEquals(outer, Schema.parse(outer.toString()));
+  }
+
+  @Test
   public void testNullPointer() throws Exception {
     String recordJson = "{\"type\":\"record\", \"name\":\"Test\", \"fields\":"
       +"[{\"name\":\"x\", \"type\":\"string\"}]}";



Mime
View raw message