[ 
https://issues.apache.org/jira/browse/AVRO-2858?focusedWorklogId=689771&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-689771
 ]

ASF GitHub Bot logged work on AVRO-2858:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 03/Dec/21 05:43
            Start Date: 03/Dec/21 05:43
    Worklog Time Spent: 10m 
      Work Description: bulbfreeman closed pull request #915:
URL: https://github.com/apache/avro/pull/915


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

            Worklog Id:     (was: 689771)
    Remaining Estimate: 0h
            Time Spent: 10m

> SchemaBuilder.GenericDefault withDefault method does not handle Double.NaN 
> correctly
> ------------------------------------------------------------------------------------
>
>                 Key: AVRO-2858
>                 URL: https://issues.apache.org/jira/browse/AVRO-2858
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.9.2
>            Reporter: Gordon Wang
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: AVRO-2858.patch
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Upgraded to Avro 1.9.2 and found when using the withDefault method in 
> SchemaBuilder.GenericDefault to set default value for a Double typed field, 
> it cannot set Double.NaN correctly, throwing out below error:
> {code}
>  Exception in thread "main" org.apache.avro.AvroTypeException: Invalid 
> default for field field: "NaN" not a "double"
>  at org.apache.avro.Schema.validateDefault(Schema.java:1540)
>  at org.apache.avro.Schema.access$500(Schema.java:87)
>  at org.apache.avro.Schema$Field.<init>(Schema.java:521)
>  at 
> org.apache.avro.SchemaBuilder$FieldBuilder.completeField(SchemaBuilder.java:2238)
>  at 
> org.apache.avro.SchemaBuilder$FieldBuilder.completeField(SchemaBuilder.java:2230)
>  at 
> org.apache.avro.SchemaBuilder$FieldBuilder.access$5300(SchemaBuilder.java:2148)
>  at 
> org.apache.avro.SchemaBuilder$GenericDefault.withDefault(SchemaBuilder.java:2545)
> {code}
> After debugging it seemed the *toJsonNode* method in SchemaBuilder is 
> returning a TextNode rather than a NUMBER typed one.
> The problem can be replicated using below sample code:
> {code}
> SchemaBuilder.FieldBuilder fieldBuilder = 
> SchemaBuilder.record("record").fields().name("field");
> Schema fieldSchema = Schema.create(Schema.Type.DOUBLE);
> SchemaBuilder.GenericDefault genericDefault = fieldBuilder.type(fieldSchema);
> genericDefault.withDefault(Double.NaN);
> // Exception thrown
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to