diff --git a/schema-resolver/src/main/java/io/apicurio/registry/resolver/DefaultSchemaResolver.java b/schema-resolver/src/main/java/io/apicurio/registry/resolver/DefaultSchemaResolver.java index 80d004e685..dee40fab63 100644 --- a/schema-resolver/src/main/java/io/apicurio/registry/resolver/DefaultSchemaResolver.java +++ b/schema-resolver/src/main/java/io/apicurio/registry/resolver/DefaultSchemaResolver.java @@ -80,15 +80,17 @@ public SchemaLookupResult resolveSchema(Record data) { Objects.requireNonNull(data.payload()); - ParsedSchema parsedSchema = null; + ParsedSchema parsedSchema; if (artifactResolverStrategy.loadSchema() && schemaParser.supportsExtractSchemaFromData()) { parsedSchema = schemaParser.getSchemaFromData(data, registerDereferenced); + } else { + parsedSchema = null; } final ArtifactReference artifactReference = resolveArtifactReference(data, parsedSchema, false, null); return getSchemaFromCache(artifactReference) - .orElse(getSchemaFromRegistry(parsedSchema, data, artifactReference)); + .orElseGet(() -> getSchemaFromRegistry(parsedSchema, data, artifactReference)); } private Optional> getSchemaFromCache(ArtifactReference artifactReference) {