You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Aljoscha Krettek (Jira)" <ji...@apache.org> on 2020/06/10 09:01:01 UTC
[jira] [Commented] (FLINK-18223) AvroSerializer does not correctly
instantiate GenericRecord
[ https://issues.apache.org/jira/browse/FLINK-18223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17130430#comment-17130430 ]
Aljoscha Krettek commented on FLINK-18223:
------------------------------------------
Hi [~nicusX], could you maybe open a PR with a fix?
> 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
> Priority: Major
> Labels: AVRO
>
> {{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)