Unable to get page 3 (or higher) of commits page since X-Total-Pages X-Total headers are removed
Hi,
In order to obtain a particular commits page with commit api, I call gitlab api using :
gitlabClient.getCommitsApi().getCommits(id, 10).page(3);
getCommits(id, 10) instanciate a Pager object with properties totalItems and totalPages setted with X-Total-Pages and X-Total. If these header are not present (for example with commits api), totalPages is -1 and kaminariNextPage is 2 (because pager Instanciation is made with a call api for first commit page). CF : https://github.com/gitlab4j/gitlab4j-api/blob/9cdc5a98005fb5026e67b40147e4d8351369cfac/src/main/java/org/gitlab4j/api/Pager.java#L123
Next, when we call "page(3)" of the pager, a NoSuchElementException is thrown due to this condition: https://github.com/gitlab4j/gitlab4j-api/blob/9cdc5a98005fb5026e67b40147e4d8351369cfac/src/main/java/org/gitlab4j/api/Pager.java#L318
The only solution is to use the deprecated java function such as:
this.gitlabClient.getCommitsApi().getCommits(id, 3, 10);
I think there are a problem with the java commit api to get a specific page since X-Total-Pages and X-Total are deleted.
Does a better practice exists or a a planned fix ?
Thank you and have a nice day.
@ldrago63 which version of gitlab4j-api do you use?
Hi @jabby
I have tried with 4.19.0 and 5.0.1.
Have a nice day.