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

This closes #5266

Signed-off-by: David Handermann <exceptionfactory@apache.org>
diff --git a/nifi-nar-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/main/java/org/apache/nifi/confluent/schemaregistry/client/RestSchemaRegistryClient.java b/nifi-nar-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/main/java/org/apache/nifi/confluent/schemaregistry/client/RestSchemaRegistryClient.java
index 33e74bc..3bc663c 100644
--- a/nifi-nar-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/main/java/org/apache/nifi/confluent/schemaregistry/client/RestSchemaRegistryClient.java
+++ b/nifi-nar-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/main/java/org/apache/nifi/confluent/schemaregistry/client/RestSchemaRegistryClient.java
@@ -194,14 +194,16 @@
             }
         }
 
+        // 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();