You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2022/01/05 06:46:00 UTC
[jira] [Commented] (AVRO-2867) Avro IDL: idl2schemata throws NullPointerException on record-valued defaults
[ https://issues.apache.org/jira/browse/AVRO-2867?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17469049#comment-17469049 ]
ASF subversion and git services commented on AVRO-2867:
-------------------------------------------------------
Commit 1aa963c44d1b9da3dfcf74acb3eeed56439332a0 in avro's branch refs/heads/dependabot/cargo/lang/rust/crc-2.1.0 from Oscar Westra van Holthe - Kind
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=1aa963c ]
AVRO-2867: Fix NullPointerException on record-valued defaults (#1412)
If the IDL file defines the schema of a field after the field, record
valued defaults cause a NullPointerException. This PR fixes that.
The fix addresses two situations:
1. The field schema itself is a forward reference
(tested by fixing the missing default value in `forward_ref.avpr`)
2. The field schema contains a forward reference
(tested by the `echo` message in the updated `simple.avdl`)
> 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
> Components: java, tools
> Reporter: Roger
> Assignee: Oscar Westra van Holthe - Kind
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.11.1
>
> Time Spent: 1h 50m
> Remaining Estimate: 0h
>
> 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)