You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Stan Rosenberg (JIRA)" <ji...@apache.org> on 2019/07/21 04:12:00 UTC

[jira] [Updated] (AVRO-2478) RecordBuilderBase.validate doesn't check nullability of composite types

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

Stan Rosenberg updated AVRO-2478:
---------------------------------
    Description: 
Builder classes generated from record.vm make use of RecordBuilderBase.validate in every setter to ensure that the passed value (primitive or composite) is compatible with the nullability of the corresponding Avro schema type.  The problem is the validation doesn't extend to composite types, namely Maps and Arrays.  This breaks the invariant that any record constructed via Builder is well-defined (i.e., can be serialized).

E.g., field of type array<string> would yield the following setter,
{code:java}
x.y.z.Builder setXXX(java.util.List<java.lang.String> value){code}
Thus, a collection with a null element will result in a record which breaks serialization, e.g.,
{code:java}
datumWriter.write(builder.setXXX(Collections.singletonList(null)).build()){code}

  was:Builder classes generated from record.vm make use of RecordBuilderBase.validate in every setter to ensure that the passed value (primitive or composite) is compatible with the nullability of the corresponding Avro schema type.  The problem is the validation doesn't extend to composite types, namely Maps and Arrays.  This breaks the invariant that any record constructed via Builder is well-defined (i.e., can be serialized).


> RecordBuilderBase.validate doesn't check nullability of composite types
> -----------------------------------------------------------------------
>
>                 Key: AVRO-2478
>                 URL: https://issues.apache.org/jira/browse/AVRO-2478
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.9.0, 1.8.2
>            Reporter: Stan Rosenberg
>            Priority: Minor
>
> Builder classes generated from record.vm make use of RecordBuilderBase.validate in every setter to ensure that the passed value (primitive or composite) is compatible with the nullability of the corresponding Avro schema type.  The problem is the validation doesn't extend to composite types, namely Maps and Arrays.  This breaks the invariant that any record constructed via Builder is well-defined (i.e., can be serialized).
> E.g., field of type array<string> would yield the following setter,
> {code:java}
> x.y.z.Builder setXXX(java.util.List<java.lang.String> value){code}
> Thus, a collection with a null element will result in a record which breaks serialization, e.g.,
> {code:java}
> datumWriter.write(builder.setXXX(Collections.singletonList(null)).build()){code}



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)