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

If a default value is set, Avro allows null values in non-nullable fields.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.8.1
    • None
    • java
    • None

    Description

      With an avro schema like

      {
        "name": "myfield",
        "type": "string",
        "default": ""
      }
      

      the following code should throw an exception

      MyObject myObject = MyObject.newBuilder().setMyfield(null).build();
      

      But instead the value of myfield is set to null, which causes an exception later when serializing myObject, because null is not a valid value for myfield.

      I believe in this case setMyfield(null) should throw an exception, independent of the value of default.
      See also
      https://stackoverflow.com/questions/38509279/generated-avro-builder-set-null-doesnt-overwrite-with-default

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              asmaier Andreas Maier
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated: