Skip to content

Removed throw Exception code that does not occur #3967

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

Conversation

Tussle0410
Copy link

Description

When selecting QueryLookupStrategy using a switch statement with Enum-defined values, if null is passed, it defaults to CreateIfNotFoundQueryLookupStrategy, which means the switch statement's default case cannot occur. Therefore, I determined that the corresponding throw Exception would never be executed.

So, I removed the code that performs the throw Exception.

Changes

Removed the throw exception part in the default case of the switch statement.

Signed-off-by: ChanHyeongLee <cksgud410@gmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 8, 2025
@mp911de
Copy link
Member

mp911de commented Aug 8, 2025

The enum comes from a different library and therefore, changes to the enum aren't directly coupled to the Spring Data JPA module. The exception is more of a safe-guard to fail when something unexpected will be passed in. Therefore, we want to keep the exception arrangement as-is.

@mp911de mp911de closed this Aug 8, 2025
@mp911de mp911de added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 8, 2025
@Tussle0410
Copy link
Author

It seems I hadn't considered that it could serve as a safeguard against unexpected errors.
Thank you for providing such a good response with your opinion.

@Tussle0410 Tussle0410 deleted the Removed-throw-Exception-code-that-does-not-occur branch August 8, 2025 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants