[
https://issues.apache.org/jira/browse/AVRO-2648?focusedWorklogId=642429&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-642429
]
ASF GitHub Bot logged work on AVRO-2648:
----------------------------------------
Author: ASF GitHub Bot
Created on: 26/Aug/21 16:28
Start Date: 26/Aug/21 16:28
Worklog Time Spent: 10m
Work Description: RyanSkraba commented on pull request #739:
URL: https://github.com/apache/avro/pull/739#issuecomment-906561363
I'm not sure what happened here -- I'm going to merge this here to close the
PR (and add the missing `@Test` attribute). Thanks!
--
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: 642429)
Remaining Estimate: 0h
Time Spent: 10m
> Incorrect validation of numeric default values
> ----------------------------------------------
>
> Key: AVRO-2648
> URL: https://issues.apache.org/jira/browse/AVRO-2648
> Project: Apache Avro
> Issue Type: Bug
> Components: java
> Reporter: Jeffrey Mullins
> Assignee: Jeffrey Mullins
> Priority: Major
> Fix For: 1.10.0
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> Validation of numeric default values is incorrect and results in API
> inconsistencies. Below are a few examples.
> Double value as int default value:
> {code:java}
> public void testDoubleAsIntDefaultValue() {
> Schema.Field field = new Schema.Field("myField",
> Schema.create(Schema.Type.INT), "doc", 1.1);
> field.hasDefaultValue(); // true
> field.defaultValue(); // internal DoubleNode (1.1)
> field.defaultVal(); // null
> GenericData.get().getDefaultValue(field); // Integer (1)
>
> field = new Schema.Field("myField", Schema.create(Schema.Type.INT),
> "doc", 1.0);
> field.hasDefaultValue(); // true
> field.defaultValue(); // internal DoubleNode (1.0)
> field.defaultVal(); // null
> GenericData.get().getDefaultValue(field); // Integer (1)
> }{code}
>
> {color:#172b4d}Invalid long as int default value:{color}
> {code:java}
> public void testInvalidLongAsIntDefault() {
> Schema.Field field = new Schema.Field("myField",
> Schema.create(Schema.Type.INT), "doc", Integer.MAX_VALUE + 1L);
> field.hasDefaultValue(); // true
> field.defaultValue(); // internal LongNode (2147483648)
> field.defaultVal(); // Long (2147483648)
> GenericData.get().getDefaultValue(field); // Integer (-2147483648)
> }{code}
> Additionally, since the underlying Schema.FIeld.defaultValue() is no longer
> public it's not possible for users to disable default value validation and
> reliably validate schemas independently.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)