mirror of https://github.com/apache/nifi.git
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:
parent
d70359d3e8
commit
2e998839eb
|
@ -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) {
|
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);
|
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 {
|
try {
|
||||||
final Schema avroSchema = new Schema.Parser().parse(schema);
|
final Schema avroSchema = new Schema.Parser().parse(schema);
|
||||||
final SchemaIdentifier schemaId = SchemaIdentifier.builder().name(name).id((long) id).version(version).build();
|
final SchemaIdentifier schemaId = SchemaIdentifier.builder().name(name).id((long) id).version(version).build();
|
||||||
|
|
Loading…
Reference in New Issue