Skip to content

Commit

Permalink
AVRO-4078: Update the namespace for FullName
Browse files Browse the repository at this point in the history
Now the test hangs while trying to initialize the static field READER$
and WRITER$

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
  • Loading branch information
martin-g committed Oct 18, 2024
1 parent 6d00e35 commit f514b34
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static <K, V> V computeIfAbsent(ConcurrentMap<K, V> map, K key, Function<
if (value != null) {
return value;
}
return map.computeIfAbsent(key, mappingFunction::apply);
return map.computeIfAbsent(key, mappingFunction);
}

}
10 changes: 5 additions & 5 deletions lang/java/avro/src/test/java/org/apache/avro/FullName.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@
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\"}}]}");
"{\"type\":\"record\",\"name\":\"FullName\",\"namespace\":\"org.apache.avro\",\"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$;
static {
WRITER$ = new SpecificDatumWriter(SCHEMA$);
READER$ = new SpecificDatumReader(SCHEMA$);
}

public FullName() {
}
Expand Down Expand Up @@ -57,8 +61,4 @@ public void put(int field$, Object value$) {

}

static {
WRITER$ = new SpecificDatumWriter(SCHEMA$);
READER$ = new SpecificDatumReader(SCHEMA$);
}
}
10 changes: 9 additions & 1 deletion lang/java/avro/src/test/java/org/apache/avro/TestAvro4078.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.apache.avro;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;

import org.apache.avro.specific.SpecificData;
import org.junit.Test;

Expand All @@ -16,6 +19,11 @@ public class TestAvro4078 {
@Test
public void testClassLoad() {
System.err.println(FULLNAME_SCHEMA);
System.err.println(SpecificData.get().getClass(FULLNAME_SCHEMA));
// assertNotNull(SpecificData.get().getClass(FULLNAME_SCHEMA));
assertSame(FullName.class, SpecificData.get().getClass(FULLNAME_SCHEMA));
}

public static void main(String[] args) {
assertSame(FullName.class, SpecificData.get().getClass(FULLNAME_SCHEMA));
}
}

0 comments on commit f514b34

Please sign in to comment.