diff --git a/avro-builder/builder/src/test/resources/test-projects/classpath-project/input/SchemaWithClasspathImport.avsc b/avro-builder/builder/src/test/resources/test-projects/classpath-project/input/SchemaWithClasspathImport.avsc index 939a47040..6a6236ad7 100644 --- a/avro-builder/builder/src/test/resources/test-projects/classpath-project/input/SchemaWithClasspathImport.avsc +++ b/avro-builder/builder/src/test/resources/test-projects/classpath-project/input/SchemaWithClasspathImport.avsc @@ -7,6 +7,23 @@ { "name": "date", "type": "build.generated.SimpleRecord" + }, + { + "name": "unionArrayReference", + "type" :[ + "null", + { + "type": "array", + "items": "build.generated.SimpleRecord" + } + ] + }, + { + "name": "mapReference", + "type": { + "type": "map", + "values": "build.generated.SimpleRecord" + } } ] } diff --git a/avro-codegen/src/main/java/com/linkedin/avroutil1/codegen/SpecificRecordGeneratorUtil.java b/avro-codegen/src/main/java/com/linkedin/avroutil1/codegen/SpecificRecordGeneratorUtil.java index 9e9b219dd..66d3a1306 100644 --- a/avro-codegen/src/main/java/com/linkedin/avroutil1/codegen/SpecificRecordGeneratorUtil.java +++ b/avro-codegen/src/main/java/com/linkedin/avroutil1/codegen/SpecificRecordGeneratorUtil.java @@ -314,10 +314,16 @@ private static List getNestedInternalSchemaListForRecord(AvroRe }); break; case MAP: - schemaQueue.add(((AvroMapSchema) fieldSchema).getValueSchema()); + AvroMapSchema mapSchema = (AvroMapSchema) fieldSchema; + if (mapSchema.getValueSchemaOrRef().getRef() == null) { + schemaQueue.add(mapSchema.getValueSchema()); + } break; case ARRAY: - schemaQueue.add(((AvroArraySchema) fieldSchema).getValueSchema()); + AvroArraySchema arraySchema = (AvroArraySchema) fieldSchema; + if (arraySchema.getValueSchemaOrRef().getRef() == null) { + schemaQueue.add(arraySchema.getValueSchema()); + } break; } }