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

ASF subversion and git services commented on AVRO-3644:
-------------------------------------------------------

Commit 627b005493bb8abe6a0ffc53c709ad1b7967c769 in avro's branch 
refs/heads/dependabot/maven/lang/java/org.apache.thrift-libthrift-0.17.0 from 
Daniel Heinrich
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=627b00549 ]

AVRO-3644: handle java.util.Optional as a nullable value (#1915)

Why:
Javas Optional type can not be used in any meaningful way with the
reflection based schema generation. It is for example not possible
to write a generic custom encoding.

How does it help with resolving the issue:
Optional can be used to make fields null safe in their usage.

Side effects:
I think that this change should not have any side effects, because
Optional fields could not have been used in the past.

> [JAVA] Support java.util.Optional in reflect package
> ----------------------------------------------------
>
>                 Key: AVRO-3644
>                 URL: https://issues.apache.org/jira/browse/AVRO-3644
>             Project: Apache Avro
>          Issue Type: Improvement
>          Components: java
>            Reporter: Daniel Heinrich
>            Assignee: Daniel Heinrich
>            Priority: Trivial
>              Labels: pull-request-available
>             Fix For: 1.12.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> java.util.Optional can currently not be used at all when using reflection 
> based schemas.
> _org.apache.avro.reflect.ReflectData#getSchema_ will currently produce the 
> following type for fields using Optional:
> {"type":"record","name":"Optional","namespace":"java.util","fields":[]}
> The generated schema is completly unusable (it does not contain any data). I 
> would like to propose to map Optional fields as if they were not using 
> Optional and would be annotated with @Nullable. So resulting in the following 
> type:
> ["null","something"]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to