avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1040338 - in /avro/trunk: CHANGES.txt lang/java/src/java/org/apache/avro/Schema.java lang/java/src/test/java/org/apache/avro/TestSchema.java
Date Mon, 29 Nov 2010 23:18:48 GMT
Author: cutting
Date: Mon Nov 29 23:18:47 2010
New Revision: 1040338

URL: http://svn.apache.org/viewvc?rev=1040338&view=rev
Log:
AVRO-702. Java: Fix a bug printing nested record namespaces.

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

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1040338&r1=1040337&r2=1040338&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Mon Nov 29 23:18:47 2010
@@ -54,6 +54,8 @@ Avro 1.5.0 (unreleased)
     AVRO-693. Java: Configure Velocity to use null logger, removing a
     dependency that was breaking the build.  (Stephen Gargan via cutting)
 
+    AVRO-702. Java: Fix a bug printing nested record namespaces. (cutting)
+
 Avro 1.4.1 (13 October 2010)
 
   NEW FEATURES

Modified: avro/trunk/lang/java/src/java/org/apache/avro/Schema.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/java/org/apache/avro/Schema.java?rev=1040338&r1=1040337&r2=1040338&view=diff
==============================================================================
--- avro/trunk/lang/java/src/java/org/apache/avro/Schema.java (original)
+++ avro/trunk/lang/java/src/java/org/apache/avro/Schema.java Mon Nov 29 23:18:47 2010
@@ -608,14 +608,17 @@ public abstract class Schema {
     }
     void toJson(Names names, JsonGenerator gen) throws IOException {
       if (writeNameRef(names, gen)) return;
+      String savedSpace = names.space;            // save namespace
       gen.writeStartObject();
       gen.writeStringField("type", isError?"error":"record");
       writeName(names, gen);
+      names.space = name.space;                   // set default namespace
       gen.writeFieldName("fields");
       fieldsToJson(names, gen);
       props.write(gen);
       aliasesToJson(gen);
       gen.writeEndObject();
+      names.space = savedSpace;                   // restore namespace
     }
 
     void fieldsToJson(Names names, JsonGenerator gen) throws IOException {

Modified: avro/trunk/lang/java/src/test/java/org/apache/avro/TestSchema.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/test/java/org/apache/avro/TestSchema.java?rev=1040338&r1=1040337&r2=1040338&view=diff
==============================================================================
--- avro/trunk/lang/java/src/test/java/org/apache/avro/TestSchema.java (original)
+++ avro/trunk/lang/java/src/test/java/org/apache/avro/TestSchema.java Mon Nov 29 23:18:47
2010
@@ -399,6 +399,18 @@ public class TestSchema {
   }
 
   @Test
+  public void testNamespaceNesting() throws Exception {
+    String y = "{\"type\":\"record\",\"name\":\"y.Y\",\"fields\":["
+      +"{\"name\":\"f\",\"type\":\"x.X\"}]}";
+    String x = "{\"type\":\"record\",\"name\":\"x.X\",\"fields\":["
+      +"{\"name\":\"f\",\"type\":"+y+"}"
+      +"]}";
+    Schema xs = Schema.parse(x);
+    System.out.println(xs);
+    assertEquals(xs, Schema.parse(xs.toString()));
+  }
+
+  @Test
   public void testNullPointer() throws Exception {
     String recordJson = "{\"type\":\"record\", \"name\":\"Test\", \"fields\":"
       +"[{\"name\":\"x\", \"type\":\"string\"}]}";



Mime
View raw message