Skip to content

Commit

Permalink
fix potential npe
Browse files Browse the repository at this point in the history
  • Loading branch information
Doris Lam committed Aug 16, 2023
1 parent bb819c8 commit bd6d9d6
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ public void onFailure() {
if (sysmlIdJsonNode == null || !sysmlIdJsonNode.isTextual()) {
continue;
}
JsonNode typeNode = entryObjectNode.get(MDKConstants.TYPE_KEY);
if (typeNode == null) { // this may happen with ve added artifacts in a beta version that's not attached to a model element
continue;
}
String entryId = sysmlIdJsonNode.asText();
// TODO Abstract this stuff to a converter @donbot
String name = null;
Expand All @@ -277,8 +281,9 @@ public void onFailure() {
name = "<>";
}
}
String type = typeNode != null ? typeNode.asText("Element") : "Element";
ValidationRuleViolation validationRuleViolation = new ValidationRuleViolation(entryElement != null && !Project.isElementDisposed(entryElement) ? entryElement : project.getPrimaryModel(), "["
+ (entryElement != null && !Project.isElementDisposed(entryElement) ? "UPDATE" : "CREATE") + " FAILED]" + (entryElement == null || Project.isElementDisposed(entryElement) ? " " + entryObjectNode.get(MDKConstants.TYPE_KEY).asText("Element") + " " + name + " : " + entryId : "")
+ (entryElement != null && !Project.isElementDisposed(entryElement) ? "UPDATE" : "CREATE") + " FAILED]" + (entryElement == null || Project.isElementDisposed(entryElement) ? " " + type + " " + name + " : " + entryId : "")
+ ((entryElement == null || Project.isElementDisposed(entryElement)) && entryException != null ? " -" : "") + (entryException != null ? " " + (entryException instanceof ReadOnlyElementException ? "Element is not editable." : entryException.getMessage()) : ""));
addUpdateElementActions(validationRuleViolation, entryElement, entryId, entryObjectNode);
(entryException instanceof ReadOnlyElementException ? editableValidationRule : failedChangeValidationRule).addViolation(validationRuleViolation);
Expand Down

0 comments on commit bd6d9d6

Please sign in to comment.