From d84b5f3fdc5c8aff2fc42ed86de7489421736223 Mon Sep 17 00:00:00 2001 From: David Leifker Date: Thu, 9 May 2024 17:05:29 -0500 Subject: [PATCH] fix(openapi): fix lookupAspectSpec --- .../openapi/v2/controller/EntityController.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/metadata-service/openapi-servlet/src/main/java/io/datahubproject/openapi/v2/controller/EntityController.java b/metadata-service/openapi-servlet/src/main/java/io/datahubproject/openapi/v2/controller/EntityController.java index 6c0da39d40ce95..d844acb6f6f979 100644 --- a/metadata-service/openapi-servlet/src/main/java/io/datahubproject/openapi/v2/controller/EntityController.java +++ b/metadata-service/openapi-servlet/src/main/java/io/datahubproject/openapi/v2/controller/EntityController.java @@ -768,11 +768,11 @@ public List toEntityListResponse( * @return */ private static AspectSpec lookupAspectSpec(EntitySpec entitySpec, String aspectName) { - return Optional.ofNullable(entitySpec.getAspectSpec(aspectName)) - .orElse( - entitySpec.getAspectSpecs().stream() - .filter(aspec -> aspec.getName().toLowerCase().equals(aspectName)) - .findFirst() - .get()); + return entitySpec.getAspectSpec(aspectName) != null + ? entitySpec.getAspectSpec(aspectName) + : entitySpec.getAspectSpecs().stream() + .filter(aspec -> aspec.getName().toLowerCase().equals(aspectName)) + .findFirst() + .get(); } }