Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #658 : Pager not working properly
Since the removal of "X-Total-Pages" and "X-Total" headers, all paginations use the kaminari counter. In this mode, kaminari counter is reset to -1 during the call of the last page. This part is correct. Then when we call the `current()` method of the pager to get the current page. This method call the same `page` method than the `next` method. In this method the pager check if there is element before checking if we call for the current page. It throws NoSuchElementException erroneously. To fix, I change the check sequence. First I check ifthe user call the current page. If so, we return the corresponding items. If not we check if there is such elements and call the API.
- Loading branch information
4e9f7a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right,which means I can only use hasNext() to determine if there has a next page? If I want to know the exact number of the total size, use pager.all().size(), but it's implementation is a loop ,sad! Maybe I should give up display the total number.
4e9f7a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LiuTing0729 I didn't try but maybe you can use
gitlab4j-api/src/main/java/org/gitlab4j/api/RepositoryApi.java
Lines 636 to 647 in db8f925