AVRO-1814: Generated java code fails on variables with a TLD name like 'org'
diff --git a/CHANGES.txt b/CHANGES.txt
index bce23ce..5f0b83b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -49,6 +49,8 @@
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
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 @@
/** Creates a new Builder */
private Builder() {
- super(#if ($schema.getNamespace())$schema.getNamespace().#end${this.mangle($schema.getName())}.SCHEMA$);
+ super(SCHEMA$);
}
/**
@@ -214,7 +217,7 @@
*/
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 @@
@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 @@
@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));
}
}
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 @@
/** Creates a new Builder */
private Builder() {
- super(avro.examples.baseball.Player.SCHEMA$);
+ super(SCHEMA$);
}
/**
@@ -198,7 +201,7 @@
* @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 @@
@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 @@
@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));
}
}
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 @@
/** Creates a new Builder */
private Builder() {
- super(avro.examples.baseball.Player.SCHEMA$);
+ super(SCHEMA$);
}
/**
@@ -198,7 +201,7 @@
* @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 @@
@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 @@
@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));
}
}
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 @@
string value;
}
+ record TopLevelDomainNames {
+ string org;
+ string avro;
+ string com;
+ string net;
+ string nl;
+ }
+
}