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

Mykola Polonskyi edited comment on AVRO-1927 at 7/16/18 8:06 PM:
-----------------------------------------------------------------

hello (bump message)

*same behavior from builder on 1.8.2 and same error onto serialization call*
 can any one share reference for spec that explain this behavior if its valid? 
or clarify status 
 tnx

cc: [~rdblue] as reporter at related issue 


was (Author: glhf_):
hello (bump message)

*same behavior from builder on 1.8.2 and same error onto serialization call*
 can any one share reference for spec that explain this behavior if its valid? 
or clarify status 
 tnx

cc: @rdblue as reporter at related issue 

> If a default value is set, Avro allows null values in non-nullable fields.
> --------------------------------------------------------------------------
>
>                 Key: AVRO-1927
>                 URL: https://issues.apache.org/jira/browse/AVRO-1927
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.8.1
>            Reporter: Andreas Maier
>            Priority: Major
>
> With an avro schema like
> {code}
> {
>   "name": "myfield",
>   "type": "string",
>   "default": ""
> }
> {code}
> the following code should throw an exception
> {code}
> MyObject myObject = MyObject.newBuilder().setMyfield(null).build();
> {code}
> But instead the value of myfield is set to null, which causes an exception 
> later when serializing myObject, because null is not a valid value for 
> myfield. 
> I believe in this case setMyfield(null) should throw an exception, 
> independent of the value of default. 
> See also
> https://stackoverflow.com/questions/38509279/generated-avro-builder-set-null-doesnt-overwrite-with-default



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to