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

setValidateDefaults=false does not seem to work

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Cannot Reproduce
    • 1.9.0
    • None
    • None
    • None

    Description

      Followup to AVRO-2035.

      I am testing 1.9 SNAPSHOT. I set `Schema.Parser.setValidateDefaults` to false, and still get a failure at compile-time if the default does not match the schema. For example, a field definition of:

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

      Should this definition succeed if `setValidateDefaults(false)` is called? If not, should the `setValidateDefaults` method just be removed?

      The exception is:

      Caused by: org.apache.avro.AvroTypeException: Invalid default for field name: null not a

      {"type":"string","avro.java.string":"String"}

      at org.apache.avro.Schema.validateDefault(Schema.java:1482)
      at org.apache.avro.Schema.access$300(Schema.java:84)
      at org.apache.avro.Schema$Field.<init>(Schema.java:493)
      at org.apache.avro.Schema$Field.<init>(Schema.java:485)
      at org.apache.avro.Schema$Field.<init>(Schema.java:504)
      at org.apache.avro.compiler.specific.SpecificCompiler.addStringType(SpecificCompiler.java:689)
      at org.apache.avro.compiler.specific.SpecificCompiler.addStringType(SpecificCompiler.java:668)
      at org.apache.avro.compiler.specific.SpecificCompiler.compile(SpecificCompiler.java:598)
      at org.apache.avro.compiler.specific.SpecificCompiler.compileToDestination(SpecificCompiler.java:527)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              rocketraman Raman Gupta
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: