You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flink.apache.org by "Lorenzo Nicora (Jira)" <ji...@apache.org> on 2020/06/09 18:34:00 UTC
[jira] [Created] (FLINK-18223) AvroSerializer does not correctly
instantiate GenericRecord
Lorenzo Nicora created FLINK-18223:
--------------------------------------
Summary: AvroSerializer does not correctly instantiate GenericRecord
Key: FLINK-18223
URL: https://issues.apache.org/jira/browse/FLINK-18223
Project: Flink
Issue Type: Bug
Components: Formats (JSON, Avro, Parquet, ORC, SequenceFile)
Affects Versions: 1.10.1
Reporter: Lorenzo Nicora
{{AvroSerializer.createInstance()}} simply calls {{InstantiationUtil.instantiate(type)}} to create a new instance, also when type is GenericRecord.
This fails with an exception, because a GenericRecord must be instantiated through {{GenericRecordBuilder}} but {{InstantiationUtil}} is not aware of it.
{code:java}
The class 'org.apache.avro.generic.GenericRecord' is not instantiable: The class is not a proper class. It is either abstract, an interface, or a primitive type.{code}
This can be proven with this test
{code:java}
@Test
public void shouldInstantiateGenericRecord() {
org.apache.avro.Schema SCHEMA = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Dummy\",\"namespace\":\"dummy\",\"fields\":[{\"name\":\"something\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}}]}");
AvroSerializer<GenericRecord> serializer = new AvroSerializer<>(GenericRecord.class, SCHEMA);
serializer.createInstance();
}
{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)