[
https://issues.apache.org/jira/browse/AVRO-2867?focusedWorklogId=685682&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-685682
]
ASF GitHub Bot logged work on AVRO-2867:
----------------------------------------
Author: ASF GitHub Bot
Created on: 24/Nov/21 08:04
Start Date: 24/Nov/21 08:04
Worklog Time Spent: 10m
Work Description: opwvhk commented on a change in pull request #1412:
URL: https://github.com/apache/avro/pull/1412#discussion_r755783782
##########
File path:
lang/java/compiler/src/main/java/org/apache/avro/compiler/idl/ResolvingVisitor.java
##########
@@ -139,10 +139,7 @@ public SchemaVisitorAction afterVisitNonTerminal(final
Schema nt) {
List<Schema.Field> fields = nt.getFields();
List<Schema.Field> newFields = new ArrayList<>(fields.size());
for (Schema.Field field : fields) {
- Schema.Field newField = new Schema.Field(field.name(),
replace.get(field.schema()), field.doc(),
- field.defaultVal(), field.order());
- copyAllProperties(field, newField);
- newFields.add(newField);
+ newFields.add(new Field(field, replace.get(field.schema())));
Review comment:
In the previous version, `field.defaultVal()` results in `null` for
**all** default values if the type is not yet resolved.
By using the `Field(Field, Schema)` constructor, the underlying JSON object
is used, preserving the default value.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 685682)
Time Spent: 20m (was: 10m)
> 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: 20m
> 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)