opwvhk commented on a change in pull request #1412:
URL: https://github.com/apache/avro/pull/1412#discussion_r755788934
##########
File path:
lang/java/compiler/src/main/java/org/apache/avro/compiler/schema/Schemas.java
##########
@@ -141,9 +140,8 @@ public static String getJavaClassName(final Schema schema) {
visited.put(schema, schema);
break;
case RECORD:
- Iterator<Schema> reverseSchemas =
schema.getFields().stream().map(Field::schema)
-
.collect(Collectors.toCollection(ArrayDeque::new)).descendingIterator();
- terminate = visitNonTerminal(visitor, schema, dq, () ->
reverseSchemas);
+ terminate = visitNonTerminal(visitor, schema, dq, () ->
schema.getFields().stream().map(Field::schema)
+
.collect(Collectors.toCollection(ArrayDeque::new)).descendingIterator());
Review comment:
By inlining the creation of the iterator, we avoid an `AvroException`
when using the `IsResolvedSchemaVisitor`.
Reason: you can't call `getFields()` on a schema that didn't have its fields
set yet.
--
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]