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

Prevent potential NullPointerExceptions #6369

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

solth
Copy link
Member

@solth solth commented Jan 16, 2025

Prevent some potential NullPointerExceptions reported by CodeQL by adding corresponding null checks.

@@ -538,12 +538,14 @@ public void show() {

private void restoreSelection(String rowKey, TreeNode parentNode) {
for (TreeNode childNode : parentNode.getChildren()) {
Copy link
Member

Choose a reason for hiding this comment

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

Can parentNode have children which are Null?

Copy link
Member Author

Choose a reason for hiding this comment

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

Potentially, yes, because children is just a list of DefaultTreeNode, itself an implementation of the interface TreeNode, and instances of every non-primitive type in Java can be null. Whether this can actually be the case in the Kitodo context is a different story, but shouldn't be the deciding factor for adding null checks, IMHO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants