Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add iterator() to SearchResult to loop over all the found issues #107

Merged
merged 3 commits into from
Mar 9, 2016

Conversation

psiegman
Copy link

Hi Bob,

I've hadded an iterator() method to the SearchResult that pages over all search results in a way that is transparant for the users.
This saves the user the effort of implementing paging themselves.

The implementation has some quirks to keep backwards compatibility with the current SearchResult api.

regards,
Paul

@nach-o-man
Copy link
Contributor

Related to #80

@bobcarroll
Copy link
Owner

Thank you!

bobcarroll added a commit that referenced this pull request Mar 9, 2016
Add iterator() to SearchResult to loop over all the found issues
@bobcarroll bobcarroll merged commit a1a0b19 into bobcarroll:master Mar 9, 2016
@mkobylarz
Copy link

This patch is not too good and I suggest to revert it.

  • it breaks contract and it is not backward compatible, because now JiraClient.searchIssues throws RuntimeException instead of JiraException (Issue.java:563)
try {
    nextIssue = getNextIssue();
} catch (JiraException e) {
    throw new RuntimeException(e);
}
  • it breaks JiraClient.searchIssues: notice that paging parameter 'startAt' to SearchResult constructor is never used, Issue.java:674):
   public SearchResult(RestClient restclient, String jql,
            String includedFields, String expandFields, Integer maxResults, Integer startAt) throws JiraException {
        this.restclient = restclient;
        this.jql = jql;
        this.includedFields = includedFields;
        this.expandFields = expandFields;
        initSearchResult(maxResults, start);
   }
  • it is quite messy and unreliable, fixing 'startAt' moved the problem forward and there is an issue in IssueIterator.getNextIssues (Issue.java:626)
    I think method should start like this (I am not sure, but it worked for me):
private List<Issue> getNextIssues() throws JiraException {
    if (issues != null) {
        startAt = startAt + issues.size();
    }

        JSON result = null;
....
....

@mkobylarz
Copy link

Next day of tracking bugs caused by this patch, Issue.java:597:

currentPage = getNextIssues().iterator();
if (currentPage == null) {
    return null;
} else {
    return currentPage.next();
}

iterator() never returns null although it may return empty iterator, I supposed author meant:
if (!currentPage.hasNext())

@bobcarroll
Copy link
Owner

@mkobylarz The null issue should be fixed in #159. The other two issues still need to be addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants