Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-3644

[JAVA] Support java.util.Optional in reflect package

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • None
    • 1.12.0
    • java

    Description

      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"]

      Attachments

        Issue Links

          Activity

            People

              DannyNullZwo Daniel Heinrich
              DannyNullZwo Daniel Heinrich
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h