-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent NPE when creating unknown metadata group and metadata #5603
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,13 +139,15 @@ public static List<SelectItem> getAddableMetadataForGroup(Ruleset ruleset, TreeN | |
ProcessFieldedMetadata fieldedMetadata = ((ProcessFieldedMetadata) metadataNode.getData()); | ||
ComplexMetadataViewInterface metadataView = fieldedMetadata.getMetadataView(); | ||
List<SelectItem> addableMetadata = new ArrayList<>(); | ||
for (MetadataViewInterface keyView : metadataView.getAddableMetadata(fieldedMetadata.getChildMetadata(), | ||
fieldedMetadata.getAdditionallySelectedFields())) { | ||
addableMetadata.add( | ||
new SelectItem(keyView.getId(), keyView.getLabel(), | ||
keyView instanceof SimpleMetadataViewInterface | ||
? ((SimpleMetadataViewInterface) keyView).getInputType().toString() | ||
: "dataTable")); | ||
if (Objects.nonNull(metadataView)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wondering why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think you are correct. This pull request is not meant to fix the underlying problem of the metadata handling but is just intended to better deal with the resulting null pointer exception. |
||
for (MetadataViewInterface keyView : metadataView.getAddableMetadata(fieldedMetadata.getChildMetadata(), | ||
fieldedMetadata.getAdditionallySelectedFields())) { | ||
addableMetadata.add( | ||
new SelectItem(keyView.getId(), keyView.getLabel(), | ||
keyView instanceof SimpleMetadataViewInterface | ||
? ((SimpleMetadataViewInterface) keyView).getInputType().toString() | ||
: "dataTable")); | ||
} | ||
} | ||
return sortMetadataList(addableMetadata, ruleset); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like better:
Not a requirement, but I think it is better readable. And,
Objects.equals()
doesnull
-checks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this particular case I disagree. The additional
Objects.equals
is not required and unnecessarily complicates this check, sinceInputType.INTEGER
is not null and therefor we do not need a null check here (calling theequals
method on constants or enums when comparing with variables is an encouraged way for avoiding null pointer exceptions). So if you do not mind I would leave this part unchanged.