Details
-
Bug
-
Status: Resolved
-
Critical
-
Resolution: Fixed
-
1.10.2
-
JDK 11, macOS.
Description
protected Object read(Object old, Schema expected, ResolvingDecoder in) throws IOException { Object datum = readWithoutConversion(old, expected, in); LogicalType logicalType = expected.getLogicalType(); if (logicalType != null) { Conversion<?> conversion = getData().getConversionFor(logicalType); // <---- bad if (conversion != null) { return convert(datum, expected, logicalType, conversion); } } return datum; }
For a logic type field in a union, getData().getConversionFor(logicalType) returns null, the cause is SpecificData.getForSchema() isn't compatible with JDK >= 9, it can't depend on Class.forName() to load user class.
diff --git a/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java b/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java index 58bc660b..33fc3418 100644 --- a/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java +++ b/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java @@ -140,15 +140,9 @@ public class SpecificData extends GenericData { */ public static SpecificData getForSchema(Schema reader) { if (reader != null && reader.getType() == Type.RECORD) { - final String className = getClassName(reader); - if (className != null) { - final Class<?> clazz; - try { - clazz = Class.forName(className); - return getForClass(clazz); - } catch (ClassNotFoundException e) { - return SpecificData.get(); - } + final Class<?> clazz = SpecificData.get().getClass(reader); + if (clazz != null) { + return getForClass(clazz); } } return SpecificData.get();
Attachments
Issue Links
- is duplicated by
-
AVRO-3156 Performance degradation in SpecificRecordBuilder introduced in 1.9.0
- Resolved
- links to