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

Java builder API fails when default value does not match the first type in a union

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.6.3
    • None
    • java
    • None

    Description

      The following definition works fine with the builder:
      record Rec {
      union

      { boolean, null } field = false;
      }

      but this one fails:
      record Rec {
      union { boolean, null }

      field = null;
      }

      Rec.newBuilder().build() fails with this error:

      org.apache.avro.AvroRuntimeException: org.apache.avro.AvroTypeException: Non-boolean default for boolean: null
      at Rec$Builder.build
      Caused by: org.apache.avro.AvroTypeException: Non-boolean default for boolean: null
      at org.apache.avro.io.parsing.ResolvingGrammarGenerator.encode(ResolvingGrammarGenerator.java:393)
      at org.apache.avro.io.parsing.ResolvingGrammarGenerator.encode(ResolvingGrammarGenerator.java:350)
      at org.apache.avro.data.RecordBuilderBase.defaultValue(RecordBuilderBase.java:178)
      at Rec$Builder.build

      Attachments

        Activity

          People

            Unassigned Unassigned
            kryzthov Christophe Taton
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: