[
https://issues.apache.org/jira/browse/AVRO-2478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16889644#comment-16889644
]
Stan Rosenberg commented on AVRO-2478:
--------------------------------------
Note this also addresses the issue raised in AVRO-1716 and AVRO-1927.
> 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}
> will throw NPE.
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)