Limit rssChangeLog feed to 20 entries by default#26422
Limit rssChangeLog feed to 20 entries by default#26422Divya07-22 wants to merge 2 commits intojenkinsci:masterfrom
Conversation
|
/label rfe |
|
The build failures are due to the yarn lockfile update check and not related to my Java changes. Please advise if further action is needed. |
There was a problem hiding this comment.
Pull request overview
Updates Jenkins core’s rssChangeLog endpoint to cap the number of changelog entries returned by default, addressing the performance concerns described in JENKINS-18992 / #14784.
Changes:
- Add a default limit (intended: 20) to the RSS changelog feed generation loop.
- Stop iterating builds/change sets once the feed item cap is reached.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for (RunT r = getLastBuild(); r != null && totalFeedItems < MAX_ENTRIES; r = r.getPreviousBuild()) { | ||
| int idx = 0; | ||
| if (r instanceof RunWithSCM) { | ||
| for (ChangeLogSet<? extends ChangeLogSet.Entry> c : ((RunWithSCM<?, ?>) r).getChangeSets()) { | ||
| for (ChangeLogSet.Entry e : c) { |
There was a problem hiding this comment.
The loop/if block structure here is broken (missing braces/indentation), which changes scoping and makes r referenced outside the for initializer scope. As written, this will not compile and also won’t iterate builds/entries as intended. Add braces so idx, the instanceof RunWithSCM check, and the nested change set loops are inside the for (RunT r = ...) body, and ensure the method braces close after the forwardToRss call (not before it).
| RSS.forwardToRss( | ||
| } | ||
| } | ||
| S.forwardToRss( |
There was a problem hiding this comment.
S.forwardToRss looks like a typo; the class used elsewhere in core is hudson.model.RSS.forwardToRss(...). As-is this will not compile unless there is an in-scope S alias/variable, and it also changes the API being called unexpectedly.
| S.forwardToRss( | |
| RSS.forwardToRss( |
| final int MAX_ENTRIES = 20; | ||
| int totalFeedItems = 0; | ||
| for (RunT r = getLastBuild(); r != null && totalFeedItems < MAX_ENTRIES; r = r.getPreviousBuild()) { |
There was a problem hiding this comment.
Hard-coding MAX_ENTRIES = 20 inside the handler makes it difficult to tune for larger/smaller instances and doesn’t satisfy the “clients can ask for full-length explicitly” requirement from the linked issue. Consider using a system property default (pattern used widely in core via jenkins.util.SystemProperties.getInteger) and allowing an optional request parameter (e.g., max) to override the default with a reasonable upper bound.
| if (totalFeedItems >= MAX_ENTRIES) break; | ||
| } | ||
| RSS.forwardToRss( | ||
| } | ||
| } | ||
| S.forwardToRss( |
There was a problem hiding this comment.
There are unmatched closing braces here (} / }) which appear to terminate the for loop and even the doRssChangelog method before the feed is rendered. This will either fail compilation or change control flow so no RSS output is produced. Please re-balance braces so forwardToRss(...) remains inside doRssChangelog.
Limit the rssChangeLog feed to 20 entries by default. Addresses performance issue reported in JENKINS-18992.
Fixes #14784
Testing done
Screenshots (UI changes only)
Before
After
Proposed changelog entries
Proposed changelog category
/label
Proposed upgrade guidelines
N/A
Submitter checklist
@Restrictedor have@since TODOJavadocs, as appropriate.@Deprecated(since = "TODO")or@Deprecated(forRemoval = true, since = "TODO"), if applicable.evalto ease future introduction of Content Security Policy (CSP) directives (see documentation).Desired reviewers
@mention
Before the changes are marked as
ready-for-merge:Maintainer checklist
upgrade-guide-neededlabel is set and there is a Proposed upgrade guidelines section in the pull request title (see example).lts-candidateto be considered.