From b003e1d600c5b14b13d802514a0ab7c561fee171 Mon Sep 17 00:00:00 2001 From: sonika-shah <58761340+sonika-shah@users.noreply.github.com> Date: Thu, 3 Oct 2024 13:25:46 +0530 Subject: [PATCH] fix: Handle NullPointerException when adding custom properties to ensure loop continues for other schemas of the same type for addToRegistry (#18088) --- .../org/openmetadata/service/TypeRegistry.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/TypeRegistry.java b/openmetadata-service/src/main/java/org/openmetadata/service/TypeRegistry.java index ff01df62db3..f92fdc8ca0e 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/TypeRegistry.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/TypeRegistry.java @@ -69,10 +69,16 @@ public class TypeRegistry { String customPropertyFQN = getCustomPropertyFQN(entityType, propertyName); CUSTOM_PROPERTIES.put(customPropertyFQN, customProperty); - JsonSchema jsonSchema = - JsonUtils.getJsonSchema(TYPES.get(customProperty.getPropertyType().getName()).getSchema()); - CUSTOM_PROPERTY_SCHEMAS.put(customPropertyFQN, jsonSchema); - LOG.info("Adding custom property {} with JSON schema {}", customPropertyFQN, jsonSchema); + try { + JsonSchema jsonSchema = + JsonUtils.getJsonSchema( + TYPES.get(customProperty.getPropertyType().getName()).getSchema()); + CUSTOM_PROPERTY_SCHEMAS.put(customPropertyFQN, jsonSchema); + LOG.info("Adding custom property {} with JSON schema {}", customPropertyFQN, jsonSchema); + } catch (Exception e) { + CUSTOM_PROPERTIES.remove(customPropertyFQN); + LOG.info("Failed to add custom property {}: {}", customPropertyFQN, e.getMessage()); + } } public JsonSchema getSchema(String entityType, String propertyName) {