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

ASF subversion and git services commented on AVRO-1401:
-------------------------------------------------------

Commit c04a17c86078431d0ae33a3045520e3ec9d9787d in avro's branch 
refs/heads/master from [~nkollar]
[ https://git-wip-us.apache.org/repos/asf?p=avro.git;h=c04a17c ]

AVRO-1401: @Nullable does not work with byte[]

This closes #229


> @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)

Reply via email to