Michael Nielson created AVRO-2879:
-------------------------------------

             Summary: Builder.build fails when enum has a default value
                 Key: AVRO-2879
                 URL: https://issues.apache.org/jira/browse/AVRO-2879
             Project: Apache Avro
          Issue Type: Bug
          Components: java
            Reporter: Michael Nielson


I would expect this schema to allow building an Avro Issue without providing a 
value for severity but it fails:
{code:json}
{
  "protocol" : "Protocol",
  "namespace" : "com.namespace",
  "types" : [ {
    "type" : "record",
    "name" : "Issue",
    "fields" : [ {
      "name" : "id",
      "type" : "string"
    }, {
      "name" : "severity",
      "type" : {
        "type" : "enum",
        "name" : "Severity",
        "symbols" : [ "Unknown", "Mild", "Moderate", "Severe" ],
        "default" : "Unknown"
      }
    } ]
  } ],
  "messages" : { }
}
{code}
{code:java}
Issue.newBuilder().setId("someId").build();
{code}
Error:
{noformat}
Field severity type:ENUM pos:4 not set and has no default value
Path in schema: --> severity
        at 
org.apache.avro.generic.GenericData.getDefaultValue(GenericData.java:1173)
        at 
org.apache.avro.data.RecordBuilderBase.defaultValue(RecordBuilderBase.java:142)
{noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to