[ 
https://issues.apache.org/jira/browse/FLINK-18223?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dawid Wysakowicz reassigned FLINK-18223:
----------------------------------------

    Assignee: Lorenzo Nicora

> 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
>            Assignee: Lorenzo Nicora
>            Priority: Major
>              Labels: AVRO, pull-request-available
>
> {{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)

Reply via email to