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

[JENKINS-60884] - Fix NPE in Run API when using getPreviousBuildsOverThreshold #4471

Merged
merged 3 commits into from
Feb 5, 2020
Merged

[JENKINS-60884] - Fix NPE in Run API when using getPreviousBuildsOverThreshold #4471

merged 3 commits into from
Feb 5, 2020

Conversation

AaronZurawski
Copy link
Contributor

@AaronZurawski AaronZurawski commented Feb 3, 2020

See JENKINS-60884.

This is fix for a NullPointerException in Run.getPreviousBuildsOverThreshold that was introduced by a refactor to add a new Run.getBuildsOverThreshold method in revision PR #4259

Proposed changelog entries

  • Fix NullPointerException when getting a list of runs with a status threshold (regression in 2.202)

Submitter checklist

  • JIRA issue is well described
  • Changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developer, depending on the change). Examples
    • Fill-in the Proposed changelog entries section only if there are breaking changes or other changes which may require extra steps from users during the upgrade
  • Appropriate autotests or explanation to why this change has no tests
  • For dependency updates: links to external changelogs and, if possible, full diffs

Maintainer checklist

Before the changes are marked as ready-for-merge:

  • There are at least 2 approvals for the pull request and no outstanding requests for change
  • Conversations in the pull request are over OR it is explicit that a reviewer does not block the change
  • Changelog entries in the PR title and/or Proposed changelog entries are correct
  • Proper changelog labels are set so that the changelog can be generated automatically
  • If the change needs additional upgrade steps from users, upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the PR title. (example)
  • If it would make sense to backport the change to LTS, a JIRA issue should exist and be labeled as lts-candidate

@timja timja added the regression-fix Pull request that fixes a regression in one of the previous Jenkins releases label Feb 3, 2020
Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

this is the method it is calling:

public @CheckForNull RunT getPreviousBuild() {

SpotBugs would have caught the bug if we were enforcing it 😢

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

I plan to merge it tomorrow if no negative feedback

@oleg-nenashev oleg-nenashev added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Feb 4, 2020
if (r != null) {
return r.getBuildsOverThreshold(numberOfBuilds, threshold);
}
return new ArrayList<>(numberOfBuilds);
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT-Non-blocking: Probably makes more sense for it to have no initial capacity

Suggested change
return new ArrayList<>(numberOfBuilds);
return new ArrayList<>();

Copy link
Contributor Author

@AaronZurawski AaronZurawski Feb 4, 2020

Choose a reason for hiding this comment

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

I agree but I chose to give it a capacity as this is what it would have returned in this case before being refactored.

My thought was to not change behavior no matter how insignificant. I can commit this suggestion if you still would recommend it after my comment.

@oleg-nenashev oleg-nenashev merged commit 23d5cf9 into jenkinsci:master Feb 5, 2020
@oleg-nenashev
Copy link
Member

Thanks for your contribution @AaronZurawski ! It should land in the next weekly

@AaronZurawski
Copy link
Contributor Author

Thanks everyone for the quick merge!

@oleg-nenashev oleg-nenashev added the bug For changelog: Minor bug. Will be listed after features label Feb 6, 2020
jeffret-b pushed a commit to jeffret-b/jenkins that referenced this pull request Feb 6, 2020
…Threshold (jenkinsci#4471)

* Added a null check to getPreviousBuildsOverThreshold.

* Cleaned up accidental newline.

* Update core/src/main/java/hudson/model/Run.java

Co-Authored-By: Zbynek Konecny <[email protected]>

Co-authored-by: Zbynek Konecny <[email protected]>
jsoref pushed a commit to jsoref/jenkins that referenced this pull request Feb 6, 2020
…Threshold (jenkinsci#4471)

* Added a null check to getPreviousBuildsOverThreshold.

* Cleaned up accidental newline.

* Update core/src/main/java/hudson/model/Run.java

Co-Authored-By: Zbynek Konecny <[email protected]>

Co-authored-by: Zbynek Konecny <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug For changelog: Minor bug. Will be listed after features ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback regression-fix Pull request that fixes a regression in one of the previous Jenkins releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants