fix: Handle NullPointerException when adding custom properties to ensure loop continues for other schemas of the same type for addToRegistry (#18088)

This commit is contained in:
sonika-shah 2024-10-03 13:25:46 +05:30 committed by GitHub
parent 1886132f41
commit b003e1d600
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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) {