refactor: add IllegalArgumentException in getMostSpecificCause Method#34826
Closed
sm9171 wants to merge 1 commit intospring-projects:mainfrom
Closed
refactor: add IllegalArgumentException in getMostSpecificCause Method#34826sm9171 wants to merge 1 commit intospring-projects:mainfrom
sm9171 wants to merge 1 commit intospring-projects:mainfrom
Conversation
- Signed-off-by: Sangmin Na <sm9171@nate.com>
Member
|
Thanks for the proposal but the method argument is not |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add null check to NestedExceptionUtils.getMostSpecificCause
Description
This pull request adds a defensive null check to the
getMostSpecificCausemethod in theNestedExceptionUtilsclass. The method now throws anIllegalArgumentExceptionwhen a null value is passed as theoriginalparameter.Motivation
The
getMostSpecificCausemethod is documented to never return null, as indicated by its JavaDoc comment: "return the most specific cause (never {@code null})". However, before this change, if a null value was passed to the method, it would attempt to callgetRootCause(null)and then potentially return null, contradicting its contract.Changes Made
Added a null check at the beginning of the
getMostSpecificCausemethod that throws anIllegalArgumentExceptionwith the message "Original exception must not be null" when the original parameter is null.Benefits
Impact
This is a non-breaking change for code that uses the method correctly (passing non-null exceptions). It only affects code that incorrectly passes null values, which would have led to unexpected behavior anyway.
The change is minimal and focused on improving robustness without altering the method's core functionality.