Skip to content

Comments

fix: Prevent NullPointerException in ModerationRequestController#3708

Closed
ADITYA-CODE-SOURCE wants to merge 1 commit intoeclipse-sw360:mainfrom
ADITYA-CODE-SOURCE:fix/moderation-npe
Closed

fix: Prevent NullPointerException in ModerationRequestController#3708
ADITYA-CODE-SOURCE wants to merge 1 commit intoeclipse-sw360:mainfrom
ADITYA-CODE-SOURCE:fix/moderation-npe

Conversation

@ADITYA-CODE-SOURCE
Copy link
Contributor

Description

Fixed potential NullPointerException in ModerationRequestController.getModerationRequestsByState method.

Changes

Changed from:

To:

Why This Fix Works

This is a standard Java idiom to avoid NullPointerException - by putting the constant string first ("open".equalsIgnoreCase(state)), if state is null, it simply returns false instead of throwing an NPE.

Testing

  • No functional changes, only null-safety improvement
  • The logic remains the same since stateOptions.get(0) is always "open"

Fixes #3705

Changed stateOptions.get(0).equalsIgnoreCase(state) to "open".equalsIgnoreCase(state)
to avoid NPE when state parameter is null.

This is a standard Java idiom - by putting the constant string first,
if state is null, it returns false instead of throwing NPE.

Fixes eclipse-sw360#3705
@GMishx GMishx added needs code review needs general test This is general testing, meaning that there is no org specific issue to check for labels Feb 23, 2026
@GMishx
Copy link
Member

GMishx commented Feb 23, 2026

@ADITYA-CODE-SOURCE please fix the PR description!

}

boolean stateOpen = stateOptions.get(0).equalsIgnoreCase(state);
boolean stateOpen = "open".equalsIgnoreCase(state);
Copy link
Member

Choose a reason for hiding this comment

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

stateOptions can never be null, stateOptions.get(0) can never be null as they are set in line 193-194

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs code review needs general test This is general testing, meaning that there is no org specific issue to check for

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Potential NullPointerException in ModerationRequestController.getModerationRequestsByState

2 participants