opwvhk commented on code in PR #1922:
URL: https://github.com/apache/avro/pull/1922#discussion_r1017074707
##########
lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java:
##########
@@ -618,8 +618,8 @@ protected Object createSchemaDefaultValue(Type type, Field
field, Schema fieldSc
defaultValue = (defaultAnnotation == null) ? null :
Schema.parseJsonToObject(defaultAnnotation.value());
if (defaultValue == null && fieldSchema.getType() == Schema.Type.UNION) {
- Schema defaultType = fieldSchema.getTypes().get(0);
- if (defaultType.getType() == Schema.Type.NULL) {
+ boolean acceptNull =
fieldSchema.getTypes().stream().map(Schema::getType).anyMatch((t) -> t ==
Schema.Type.NULL);
+ if (acceptNull) {
Review Comment:
One can also call `fieldSchema.isNullable()` here
--
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]