Skip to content
Open
Changes from all 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
11 changes: 7 additions & 4 deletions src/main/java/org/jenkinsci/plugins/p4/client/ClientHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -1167,12 +1167,15 @@ public long getClientHead(P4Ref from, P4Ref to) throws Exception {
* @throws Exception push up stack
*/
public long getClientHead() throws Exception {
// try to find last change
long head = getClientHead(null, null);
if (head != 0L) {
return head;
}

// get last change in server, may return shelved CLs
String latestChange = getConnection().getCounter("change");
Copy link
Contributor

@skumar7322 skumar7322 Jan 15, 2026

Choose a reason for hiding this comment

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

Thanks for creating this PR, Your change improved the performance but this may introduce a bug. Following are my comments:

This will always return latest change on the server. Will not consider client view mapping.
So in your case: if head is 0 then also it will return the latest change from counter which may be of other clients.

long head = getClientHead(null, to);
This will return latest change using the client view mapping. The counter change is just to limit and never return unless the counter change is of client mapping.

Also previous we used getClientHead(null, null); but this was changed to fix the issue of "continuously triggering dormant projects with each new submit."

long latest = Long.parseLong(latestChange);
P4Ref to = new P4ChangeRef(latest);
long head = getClientHead(null, to);
return (head == 0L) ? latest : head;
return Long.parseLong(latestChange);
}

public List<IChangelistSummary> getPendingChangelists(boolean includeLongDescription, String clientName) throws Exception {
Expand Down