avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gabor Szadovszky (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-1401) @Nullable does not work with byte[]
Date Tue, 13 Jun 2017 13:06:01 GMT

    [ https://issues.apache.org/jira/browse/AVRO-1401?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16047857#comment-16047857
] 

Gabor Szadovszky commented on AVRO-1401:
----------------------------------------

+1
Wait another day and will commit if there are no more comments.

> @Nullable does not work with byte[]
> -----------------------------------
>
>                 Key: AVRO-1401
>                 URL: https://issues.apache.org/jira/browse/AVRO-1401
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.5
>            Reporter: dennis lucero
>            Assignee: Nandor Kollar
>              Labels: java, reflection, union
>
> @Nullable does not seem to be compatible with byte[] (Avro type bytes)
> {code:java}
> public static void main(String[] args) throws IOException
> {
>     Schema schema = ReflectData.get().getSchema(MyRecord.class);
>     DatumWriter<?> protocol = ReflectData.get().createDatumWriter(schema);
>     DataFileWriter<MyRecord> writer = new DataFileWriter(protocol).create(schema,
System.out);
>     writer.append(new MyRecord());
>     writer.close();
> }
> public static class MyRecord {
>     @Nullable
>     byte[] bytes = "foo".getBytes();
> }
> {code}
> {code}
> org.apache.avro.UnresolvedUnionException: Not in union ["null",{"type":"bytes","java-class":"[B"}]:
[B@6d3f1f92
> 	at org.apache.avro.generic.GenericData.resolveUnion(GenericData.java:600)
> 	at org.apache.avro.generic.GenericDatumWriter.resolveUnion(GenericDatumWriter.java:151)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:71)
> 	at org.apache.avro.reflect.ReflectDatumWriter.write(ReflectDatumWriter.java:143)
> 	at org.apache.avro.generic.GenericDatumWriter.writeField(GenericDatumWriter.java:114)
> 	at org.apache.avro.reflect.ReflectDatumWriter.writeField(ReflectDatumWriter.java:175)
> 	at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:104)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:66)
> 	at org.apache.avro.reflect.ReflectDatumWriter.write(ReflectDatumWriter.java:143)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:58)
> 	at org.apache.avro.file.DataFileWriter.append(DataFileWriter.java:257)
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message