Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions core/src/main/java/hudson/model/Job.java
Original file line number Diff line number Diff line change
Expand Up @@ -1165,17 +1165,22 @@ class FeedItem {
scmDisplayName = " " + String.join(", ", scmNames);
}

for (RunT r = getLastBuild(); r != null; r = r.getPreviousBuild()) {
int idx = 0;
if (r instanceof RunWithSCM) {
for (ChangeLogSet<? extends ChangeLogSet.Entry> c : ((RunWithSCM<?, ?>) r).getChangeSets()) {
for (ChangeLogSet.Entry e : c) {
entries.add(new FeedItem(e, idx++));
}
}
final int MAX_ENTRIES = 20;
int totalFeedItems = 0;
for (RunT r = getLastBuild(); r != null && totalFeedItems < MAX_ENTRIES; r = r.getPreviousBuild()) {
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
int idx = 0;
if (r instanceof RunWithSCM) {
for (ChangeLogSet<? extends ChangeLogSet.Entry> c : ((RunWithSCM<?, ?>) r).getChangeSets()) {
for (ChangeLogSet.Entry e : c) {
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
if (totalFeedItems >= MAX_ENTRIES) break;
entries.add(new FeedItem(e, idx++));
totalFeedItems++;
}
if (totalFeedItems >= MAX_ENTRIES) break;
}
RSS.forwardToRss(
}
}
S.forwardToRss(
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
S.forwardToRss(
RSS.forwardToRss(

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
getDisplayName() + scmDisplayName + " changes",
getUrl() + "changes",
entries, new FeedAdapter<>() {
Expand Down