You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by ni...@apache.org on 2016/04/28 22:53:15 UTC

avro git commit: AVRO-1814: Generated java code fails on variables with a TLD name like 'org'

Repository: avro
Updated Branches:
  refs/heads/master ea242ffa2 -> 4cac7c898


AVRO-1814: Generated java code fails on variables with a TLD name like 'org'


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

Branch: refs/heads/master
Commit: 4cac7c8980791856c3fb7d3377d249cf8dd44b86
Parents: ea242ff
Author: Niels Basjes <ni...@apache.org>
Authored: Thu Apr 28 22:46:07 2016 +0200
Committer: Niels Basjes <ni...@apache.org>
Committed: Thu Apr 28 22:46:07 2016 +0200

----------------------------------------------------------------------
 CHANGES.txt                                              |  2 ++
 .../compiler/specific/templates/java/classic/record.vm   | 11 +++++++----
 .../output-string/avro/examples/baseball/Player.java     | 11 +++++++----
 lang/java/tools/src/test/compiler/output/Player.java     | 11 +++++++----
 share/test/schemas/specialtypes.avdl                     |  8 ++++++++
 5 files changed, 31 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/avro/blob/4cac7c89/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index bce23ce..5f0b83b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -49,6 +49,8 @@ Trunk (not yet released)
 
     AVRO-1826: build.sh rat fails over extra license files and many others (nielsbasjes).
 
+    AVRO-1814: Generated java code fails on variables with a TLD name like 'org' (nielsbasjes)
+
 Avro 1.8.0 (22 January 2016)
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/avro/blob/4cac7c89/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
----------------------------------------------------------------------
diff --git a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
index 3c69396..d0c1968 100644
--- a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
+++ b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
@@ -18,6 +18,9 @@
 #if ($schema.getNamespace())
 package $schema.getNamespace();  
 #end
+
+import org.apache.avro.specific.SpecificData;
+
 @SuppressWarnings("all")
 #if ($schema.getDoc())
 /** $schema.getDoc() */
@@ -186,7 +189,7 @@ public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends or
 
     /** Creates a new Builder */
     private Builder() {
-      super(#if ($schema.getNamespace())$schema.getNamespace().#end${this.mangle($schema.getName())}.SCHEMA$);
+      super(SCHEMA$);
     }
     
     /**
@@ -214,7 +217,7 @@ public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends or
      */
     private Builder(#if ($schema.getNamespace())$schema.getNamespace().#end${this.mangle($schema.getName())} other) {
       #if ($schema.isError())super(other)#else
-      super(#if ($schema.getNamespace())$schema.getNamespace().#end${this.mangle($schema.getName())}.SCHEMA$)#end;
+      super(SCHEMA$)#end;
 #foreach ($field in $schema.getFields())
       if (isValidValue(fields()[$field.pos()], other.${this.mangle($field.name(), $schema.isError())})) {
         this.${this.mangle($field.name(), $schema.isError())} = data().deepCopy(fields()[$field.pos()].schema(), other.${this.mangle($field.name(), $schema.isError())});
@@ -377,7 +380,7 @@ public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends or
 
   @Override public void writeExternal(java.io.ObjectOutput out)
     throws java.io.IOException {
-    WRITER$.write(this, org.apache.avro.specific.SpecificData.getEncoder(out));
+    WRITER$.write(this, SpecificData.getEncoder(out));
   }
 
   private static final org.apache.avro.io.DatumReader
@@ -385,7 +388,7 @@ public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends or
 
   @Override public void readExternal(java.io.ObjectInput in)
     throws java.io.IOException {
-    READER$.read(this, org.apache.avro.specific.SpecificData.getDecoder(in));
+    READER$.read(this, SpecificData.getDecoder(in));
   }
 
 }

http://git-wip-us.apache.org/repos/asf/avro/blob/4cac7c89/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java
----------------------------------------------------------------------
diff --git a/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java b/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java
index 46a0cba..9d7fbc8 100644
--- a/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java
+++ b/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java
@@ -4,6 +4,9 @@
  * DO NOT EDIT DIRECTLY
  */
 package avro.examples.baseball;  
+
+import org.apache.avro.specific.SpecificData;
+
 @SuppressWarnings("all")
 /** 選手 is Japanese for player. */
 @org.apache.avro.specific.AvroGenerated
@@ -166,7 +169,7 @@ public class Player extends org.apache.avro.specific.SpecificRecordBase implemen
 
     /** Creates a new Builder */
     private Builder() {
-      super(avro.examples.baseball.Player.SCHEMA$);
+      super(SCHEMA$);
     }
     
     /**
@@ -198,7 +201,7 @@ public class Player extends org.apache.avro.specific.SpecificRecordBase implemen
      * @param other The existing instance to copy.
      */
     private Builder(avro.examples.baseball.Player other) {
-            super(avro.examples.baseball.Player.SCHEMA$);
+            super(SCHEMA$);
       if (isValidValue(fields()[0], other.number)) {
         this.number = data().deepCopy(fields()[0].schema(), other.number);
         fieldSetFlags()[0] = true;
@@ -396,7 +399,7 @@ public class Player extends org.apache.avro.specific.SpecificRecordBase implemen
 
   @Override public void writeExternal(java.io.ObjectOutput out)
     throws java.io.IOException {
-    WRITER$.write(this, org.apache.avro.specific.SpecificData.getEncoder(out));
+    WRITER$.write(this, SpecificData.getEncoder(out));
   }
 
   private static final org.apache.avro.io.DatumReader
@@ -404,7 +407,7 @@ public class Player extends org.apache.avro.specific.SpecificRecordBase implemen
 
   @Override public void readExternal(java.io.ObjectInput in)
     throws java.io.IOException {
-    READER$.read(this, org.apache.avro.specific.SpecificData.getDecoder(in));
+    READER$.read(this, SpecificData.getDecoder(in));
   }
 
 }

http://git-wip-us.apache.org/repos/asf/avro/blob/4cac7c89/lang/java/tools/src/test/compiler/output/Player.java
----------------------------------------------------------------------
diff --git a/lang/java/tools/src/test/compiler/output/Player.java b/lang/java/tools/src/test/compiler/output/Player.java
index ce05afd..bf0ed62 100644
--- a/lang/java/tools/src/test/compiler/output/Player.java
+++ b/lang/java/tools/src/test/compiler/output/Player.java
@@ -4,6 +4,9 @@
  * DO NOT EDIT DIRECTLY
  */
 package avro.examples.baseball;  
+
+import org.apache.avro.specific.SpecificData;
+
 @SuppressWarnings("all")
 /** 選手 is Japanese for player. */
 @org.apache.avro.specific.AvroGenerated
@@ -166,7 +169,7 @@ public class Player extends org.apache.avro.specific.SpecificRecordBase implemen
 
     /** Creates a new Builder */
     private Builder() {
-      super(avro.examples.baseball.Player.SCHEMA$);
+      super(SCHEMA$);
     }
     
     /**
@@ -198,7 +201,7 @@ public class Player extends org.apache.avro.specific.SpecificRecordBase implemen
      * @param other The existing instance to copy.
      */
     private Builder(avro.examples.baseball.Player other) {
-            super(avro.examples.baseball.Player.SCHEMA$);
+            super(SCHEMA$);
       if (isValidValue(fields()[0], other.number)) {
         this.number = data().deepCopy(fields()[0].schema(), other.number);
         fieldSetFlags()[0] = true;
@@ -396,7 +399,7 @@ public class Player extends org.apache.avro.specific.SpecificRecordBase implemen
 
   @Override public void writeExternal(java.io.ObjectOutput out)
     throws java.io.IOException {
-    WRITER$.write(this, org.apache.avro.specific.SpecificData.getEncoder(out));
+    WRITER$.write(this, SpecificData.getEncoder(out));
   }
 
   private static final org.apache.avro.io.DatumReader
@@ -404,7 +407,7 @@ public class Player extends org.apache.avro.specific.SpecificRecordBase implemen
 
   @Override public void readExternal(java.io.ObjectInput in)
     throws java.io.IOException {
-    READER$.read(this, org.apache.avro.specific.SpecificData.getDecoder(in));
+    READER$.read(this, SpecificData.getDecoder(in));
   }
 
 }

http://git-wip-us.apache.org/repos/asf/avro/blob/4cac7c89/share/test/schemas/specialtypes.avdl
----------------------------------------------------------------------
diff --git a/share/test/schemas/specialtypes.avdl b/share/test/schemas/specialtypes.avdl
index 623e016..1be3aab 100644
--- a/share/test/schemas/specialtypes.avdl
+++ b/share/test/schemas/specialtypes.avdl
@@ -95,4 +95,12 @@ protocol LetsBreakIt {
       string value;
     }
 
+    record TopLevelDomainNames {
+      string org;
+      string avro;
+      string com;
+      string net;
+      string nl;
+    }
+
 }