[
https://issues.apache.org/jira/browse/AVRO-1007?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Doug Cutting updated AVRO-1007:
-------------------------------
Attachment: AVRO-1007.patch
Good point. It fixes builder to be consistent with ResolvingDecoder and the
spec in using the first type of the union for defaults, but ot does not fix the
issue you mention aove, where no default is specified yet a null is the first
type in the union.
ResolvingDecoder does currently implement this correctly, failing if no default
value is specified in the schema even if the schema is a union with null as its
first value.
Here's a patch that fixes the builder API to conform to the spec in this case
too.
There's a separate question about whether we should change the spec so that the
default value for default values is not unspecified but null. That would
permit folks to use schemas like the one you have above. It would require some
minor changes to ResolvingDecoder and to this patch.
> Insufficient validation in generated specific record builder implementations
> ----------------------------------------------------------------------------
>
> Key: AVRO-1007
> URL: https://issues.apache.org/jira/browse/AVRO-1007
> Project: Avro
> Issue Type: Bug
> Affects Versions: 1.6.1
> Reporter: James Baldassari
> Assignee: James Baldassari
> Labels: java
> Fix For: 1.6.2
>
> Attachments: AVRO-1007-v2.patch, AVRO-1007-v3.patch,
> AVRO-1007-v4.patch, AVRO-1007.patch, AVRO-1007.patch, AVRO-1007.patch,
> AVRO-1007.patch
>
>
> The are two main problems with the generated build() method in specific
> record builders:
> * For non-primitive types, if there is no default value and the user does not
> set the value, build() will execute successfully without throwing an exception
> ** Instead, an AvroRuntimeException should be thrown with an exception
> message indicating the name of the required field that was not set
> * For primitive types, if there is no default value and the user does not set
> the value, an AvroRuntimeException is thrown with the 'cause' set to a
> NullPointerException, which is not very helpful
> ** The NPE comes from attempting to set the primitive field to the result of
> defaultValue(), which is null
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira