From f82cf0482347b45e8b9e379be14ae40d2082a95f Mon Sep 17 00:00:00 2001 From: Carles Arnal Date: Mon, 2 Dec 2024 16:03:58 +0100 Subject: [PATCH] Fix incorrect orElse usage (#5638) --- .../apicurio/registry/resolver/DefaultSchemaResolver.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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) {