Skip to content
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

Fix IllegalStateException: No logical node selected! #5993

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can potentially create a NullPointerException because the result of DataEditorService.getStructuralElementView is also passed as last parameter to ProcessService.findLinkableChildProcesses where .contains is called on it without a null-check:

if (allowedStructuralElementTypes.contains(getBaseType(process.getId()))) {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because allowedSubstructuralElements is the result of Map.keySet() which cannot be null.

BTW, this is not the problem here. The problem was that the calling method expects null in case there is nothing (and there are severeal more correct return null; statements below in getStructuralElementView()), but in this one place the function throws an IllegalStateException instead of returning null.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but AddDocStrucTypeDialog.search definitely calls a method on the result of DataEditorService.getStructuralElementView (DataEditorService.getStructuralElementView(this.dataEditor).getAllowedSubstructuralElements(), to be specific), that will definitely result in a NullPointerException when getStructuralElementView is changed to return null:

Set<String> allowedSubstructuralElements = DataEditorService.getStructuralElementView(this.dataEditor)

It looks to me that the other cases where null is returned are problematic as well, because the resulting NullPointerException is not handled anywhere.

Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public static StructuralElementViewInterface getStructuralElementView(DataEditor
TreeNode selectedLogicalNode = dataEditor.getStructurePanel().getSelectedLogicalNode();

if (Objects.isNull(selectedLogicalNode)) {
throw new IllegalStateException("No logical node selected!");
return null;
}

if (!(selectedLogicalNode.getData() instanceof StructureTreeNode)) {
Expand Down