[ https://issues.apache.org/jira/browse/AVRO-2867?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17448111#comment-17448111 ]
Oscar Westra van Holthe - Kind commented on AVRO-2867: ------------------------------------------------------ This bug is triggered because {{S}} is a forward reference. A full fix consists of two parts: # When resolving types, use the {{Field(Field, Schema)}} constructor (this fixes the NPE) # When parsing the schema, check whether the field type is fully resolved (this also fixes the situation where the immediate type was resolved, but one of the fields was not) > Avro IDL: idl2schemata throws NullPointerException on record-valued defaults > ---------------------------------------------------------------------------- > > Key: AVRO-2867 > URL: https://issues.apache.org/jira/browse/AVRO-2867 > Project: Apache Avro > Issue Type: Bug > Reporter: Roger > Priority: Major > > I ran the idl2schemata tool (using avro-tools release-1.10.0-rc1) on this > avdl file: > {code:none} > protocol p { > record R { > S S = {"x": 1234}; > } > record S { > int x; > } > } > {code} > I get the following exception: > {code:none} > Exception in thread "main" java.lang.NullPointerException > at > org.apache.avro.util.internal.JacksonUtils.toObject(JacksonUtils.java:164) > at org.apache.avro.Schema$Field.defaultVal(Schema.java:632) > at > org.apache.avro.compiler.idl.ResolvingVisitor.afterVisitNonTerminal(ResolvingVisitor.java:143) > at > org.apache.avro.compiler.schema.Schemas.lambda$visitNonTerminal$1(Schemas.java:189) > at org.apache.avro.compiler.schema.Schemas.visit(Schemas.java:117) > at > org.apache.avro.compiler.idl.SchemaResolver.resolve(SchemaResolver.java:99) > at org.apache.avro.compiler.idl.Idl.CompilationUnit(Idl.java:135) > at org.apache.avro.tool.IdlToSchemataTool.run(IdlToSchemataTool.java:49) > at org.apache.avro.tool.Main.run(Main.java:67) > at org.apache.avro.tool.Main.main(Main.java:56) > {code} > I would expect the following output instead: > {code:json} > { > "type" : "record", > "name" : "R", > "fields" : [ { > "name" : "S", > "default": {"x": 1234}, > "type" : { > "type" : "record", > "name" : "S", > "fields" : [ { > "name" : "x", > "type" : "int" > } ] > } > } ] > } > {code} -- This message was sent by Atlassian Jira (v8.20.1#820001)