[jira] [Commented] (AVRO-1401) @Nullable does not work with byte[]

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[jira] [Commented] (AVRO-1401) @Nullable does not work with byte[]

JIRA jira@apache.org

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

ASF GitHub Bot commented on AVRO-1401:
--------------------------------------

GitHub user nandorKollar opened a pull request:

    https://github.com/apache/avro/pull/229

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

   

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/nandorKollar/avro AVRO-1401

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/avro/pull/229.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #229
   
----
commit 7f438cd8f7e7cae79de79e171b6bae50cd46cf96
Author: Nandor Kollar <[hidden email]>
Date:   2017-06-08T22:44:37Z

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

----


> @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
>              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.3.15#6346)
Loading...