-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Fix NPE in ReverseBuildTrigger due to null upstream threshold #23916
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 NPE in ReverseBuildTrigger due to null upstream threshold #23916
Conversation
|
/label bug |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR addresses a NullPointerException in Result.fromString() that occurs when the method receives a null input, as reported in JENKINS-39044. The fix adds a null check to return FAILURE immediately if the input is null.
Key Changes:
- Removed
@NonNullannotation from thefromString()method parameter - Added null check that returns
FAILUREfor null inputs
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
You're changing a complete different method than indicated in the stack trace. Please explain why. Were you able to reproduce the reported issue and encounter a different error? If so, what are the current steps to reproduce this? If not, what gives you any confidence that this change is useful? Also, please do not delete the PR template, it exists for a reason. |
|
Thank you for the review! @daniel-beck Regarding the code change, I identified that fromString was not null-safe and looked like a potential cause, but I admit I haven't reproduced the exact stack trace locally yet. I will go back, reproduce the specific crash reported in the issue, and ensure my fix targets the correct method. I'll update the PR shortly. |
320d93a to
b7d6a94
Compare
|
Thanks for the review! Once again I have updated the PR to:
Ready for re-review. @daniel-beck |
|
Is this the right approach? The parameter was originally annotated with Also note that we no longer use Jira ticket. Please refer to issue #17611 and adjust the title. |
|
@mawinter69 Thanks for the correction! You made a very valid point regarding the "@nonnull" contract on "Result". I cured the symptom, but not the disease. |
b7d6a94 to
d147200
Compare
|
@mawinter69
|
d147200 to
a66a7b0
Compare
|
This will also fix #17725 |
|
Very Sorry Guys, I was a little inactive cause of some university's projects, tests and all |
|
Can you provide the steps how to reproduce the NPE |
|
Sure! @mawinter69 |
|
@jenkinsci/core-pr-reviewers , @daniel-beck, gentle ping |
Has the same result as the deprecated constructor that was used before.
If the ReverseTrigger threshold were null, a null pointer exception would be thrown. The config round trip operation resets a null threshold to SUCCESS, so this test reaches inside the job definition and changes the threshold directly. Testing done: * Confirmed that the modified automated test fails when the change to ReverseTrigger is removed. * Confirmed that the modified automated test passes when the change to ReverseTrigger is included.
MarkEWaite
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've extended an existing automated test to cover this fix. Thanks for the pull request!
MarkEWaite
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is now ready for merge. We will merge it after approximately 24 hours if there is no negative feedback.
/label ready-for-merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
test/src/test/java/jenkins/triggers/ReverseBuildTriggerTest.java
Outdated
Show resolved
Hide resolved
|
Congratulations on getting your very first Jenkins core pull request merged 🎉🥳 |

Fixes #17611
Description
Fixes a "NullPointerException" in "ReverseBuildTrigger" when the upstream threshold is null.
As noted in the discussion, "Result.isBetterOrEqualTo" contract requires a non-null parameter. Instead of modifying the core "Result" class, this patch adds a safety check in "ReverseBuildTrigger.shouldTrigger". If "threshold" is null , it now defaults to "Result.SUCCESS" to prevent the crash.
Testing done
Proposed changelog entries
Proposed changelog category
/label bug
Proposed upgrade guidelines
N/A
Submitter checklist
@Restrictedor have@since TODOJavadocs, as appropriate.@Deprecated(since = "TODO")or@Deprecated(forRemoval = true, since = "TODO"), if applicable.Desired reviewers
@jenkinsci/core-pr-reviewers
Maintainer checklist
upgrade-guide-neededlabel is set and there is a Proposed upgrade guidelines section in the pull request title.lts-candidateto be considered.