You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by mg...@apache.org on 2024/10/17 08:28:38 UTC
(avro) branch avro-4078-test-case created (now 6d00e35f4)
This is an automated email from the ASF dual-hosted git repository.
mgrigorov pushed a change to branch avro-4078-test-case
in repository https://gitbox.apache.org/repos/asf/avro.git
at 6d00e35f4 AVRO-4078: [Java] Add the test classes from the reproducer
This branch includes the following new commits:
new 6d00e35f4 AVRO-4078: [Java] Add the test classes from the reproducer
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(avro) 01/01: AVRO-4078: [Java] Add the test classes from the reproducer
Posted by mg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mgrigorov pushed a commit to branch avro-4078-test-case
in repository https://gitbox.apache.org/repos/asf/avro.git
commit 6d00e35f437f8c840a8d87bce53212b833f3fc94
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
AuthorDate: Thu Oct 17 11:21:54 2024 +0300
AVRO-4078: [Java] Add the test classes from the reproducer
Signed-off-by: Martin Tzvetanov Grigorov <mg...@apache.org>
---
.../src/test/java/org/apache/avro/FullName.java | 64 ++++++++++++++++++++++
.../test/java/org/apache/avro/TestAvro4078.java | 21 +++++++
2 files changed, 85 insertions(+)
diff --git a/lang/java/avro/src/test/java/org/apache/avro/FullName.java b/lang/java/avro/src/test/java/org/apache/avro/FullName.java
new file mode 100644
index 000000000..a52215f56
--- /dev/null
+++ b/lang/java/avro/src/test/java/org/apache/avro/FullName.java
@@ -0,0 +1,64 @@
+package org.apache.avro;
+
+import org.apache.avro.AvroRuntimeException;
+import org.apache.avro.Schema;
+import org.apache.avro.io.DatumReader;
+import org.apache.avro.io.DatumWriter;
+import org.apache.avro.specific.AvroGenerated;
+import org.apache.avro.specific.SpecificDatumReader;
+import org.apache.avro.specific.SpecificDatumWriter;
+import org.apache.avro.specific.SpecificRecord;
+import org.apache.avro.specific.SpecificRecordBase;
+
+@AvroGenerated
+public class FullName extends SpecificRecordBase implements SpecificRecord {
+ private static final long serialVersionUID = 4560514203639509981L;
+ public static final Schema SCHEMA$ = (new Schema.Parser()).parse(
+ "{\"type\":\"record\",\"name\":\"FullName\",\"namespace\":\"com.example\",\"fields\":[{\"name\":\"first\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"last\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}}]}");
+ private String first;
+ private String last;
+ private static final DatumWriter WRITER$;
+ private static final DatumReader READER$;
+
+ public FullName() {
+ }
+
+ public FullName(String first, String last) {
+ this.first = first;
+ this.last = last;
+ }
+
+ public Schema getSchema() {
+ return SCHEMA$;
+ }
+
+ public Object get(int field$) {
+ switch (field$) {
+ case 0:
+ return this.first;
+ case 1:
+ return this.last;
+ default:
+ throw new AvroRuntimeException("Bad index");
+ }
+ }
+
+ public void put(int field$, Object value$) {
+ switch (field$) {
+ case 0:
+ this.first = (String) value$;
+ break;
+ case 1:
+ this.last = (String) value$;
+ break;
+ default:
+ throw new AvroRuntimeException("Bad index");
+ }
+
+ }
+
+ static {
+ WRITER$ = new SpecificDatumWriter(SCHEMA$);
+ READER$ = new SpecificDatumReader(SCHEMA$);
+ }
+}
diff --git a/lang/java/avro/src/test/java/org/apache/avro/TestAvro4078.java b/lang/java/avro/src/test/java/org/apache/avro/TestAvro4078.java
new file mode 100644
index 000000000..59b2d0d49
--- /dev/null
+++ b/lang/java/avro/src/test/java/org/apache/avro/TestAvro4078.java
@@ -0,0 +1,21 @@
+package org.apache.avro;
+
+import org.apache.avro.specific.SpecificData;
+import org.junit.Test;
+
+/**
+ * Unit test for demonstrating specific data potential issue.
+ */
+public class TestAvro4078 {
+
+ public static final Schema FULLNAME_SCHEMA = (new Schema.Parser()).parse("{\n" + " \"type\": \"record\",\n"
+ + " \"namespace\": \"org.apache.avro\",\n" + " \"name\": \"FullName\",\n" + " \"fields\": [\n"
+ + " { \"name\": \"first\", \"type\": \"string\" },\n"
+ + " { \"name\": \"last\", \"type\": \"string\" }\n" + " ]\n" + "}");
+
+ @Test
+ public void testClassLoad() {
+ System.err.println(FULLNAME_SCHEMA);
+ System.err.println(SpecificData.get().getClass(FULLNAME_SCHEMA));
+ }
+}