NIFI-8966 - Confluent Schema Registry - get schema without subject/version

This closes #5266

Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
Pierre Villard 2021-07-31 14:37:51 +02:00 committed by exceptionfactory
parent d70359d3e8
commit 2e998839eb
No known key found for this signature in database
GPG Key ID: 29B6A52D2AAE8DBA
1 changed files with 4 additions and 2 deletions

View File

@ -194,14 +194,16 @@ public class RestSchemaRegistryClient implements SchemaRegistryClient {
}
}
// At this point, we could not get a subject/version associated to the schema and its ID
// we add the schema and its ID in the cache without a subject/version
if(completeSchema == null) {
throw new SchemaNotFoundException("Could not get schema with id: " + schemaId);
return createRecordSchema(null, null, schemaId, schemaJson.get(SCHEMA_TEXT_FIELD_NAME).asText());
}
return createRecordSchema(completeSchema);
}
private RecordSchema createRecordSchema(final String name, final int version, final int id, final String schema) throws SchemaNotFoundException {
private RecordSchema createRecordSchema(final String name, final Integer version, final int id, final String schema) throws SchemaNotFoundException {
try {
final Schema avroSchema = new Schema.Parser().parse(schema);
final SchemaIdentifier schemaId = SchemaIdentifier.builder().name(name).id((long) id).version(version).build();