Skip to content

Commit

Permalink
fix: Handle NullPointerException when adding custom properties to ens…
Browse files Browse the repository at this point in the history
…ure loop continues for other schemas of the same type for addToRegistry
  • Loading branch information
sonika-shah committed Sep 29, 2024
1 parent 94b8515 commit 6ad168a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,17 @@ private void addCustomProperty(
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ private List<TermReference> getTermReferences(CSVPrinter printer, CSVRecord csvR
// List should have even numbered terms - termName and endPoint
importFailure(
printer,
invalidField(6, "References should be given in the format referenceName:endpoint url."),
invalidField(
6, "Term References should be given in the format referenceName:endpoint url."),
csvRecord);
processRecord = false;
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ record = ",g1,dsp1,dsc1,h1;h2;h3,,term1:http://term1,,,,,";
getFailedRecord(
record,
invalidField(
6, "References should be given in the format referenceName:endpoint url."))
6, "Term References should be given in the format referenceName:endpoint url."))
};
assertRows(result, expectedRows);

Expand Down

0 comments on commit 6ad168a

Please sign in to comment.