1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2025-07-01 00:25:00 +02:00

fix: paging with load balancer going to endless loop

When used with a load balanced Jira, the SearchPages method would end
up in an endless loop. This was caused by a bug where Jira would not
handle the MaxResults=50 that is sent by defaul properly, thus retur-
ning no issues. The SearchPages method didn't check for empty results
and ended up in an endless loop.

Fixed this by
1. Pre-escaping '&maxResults' to '&MaxResults'.
2. Adding a check in SearchPages to see if the issues array is empty
   before going into the endless 'for'.

Also fixed the appropriate tests.

Fixes issue #260.
This commit is contained in:
Dick Appel
2020-03-05 14:57:30 +01:00
committed by Wes McNamee
parent 436469b62d
commit 19d3fc0aec
2 changed files with 39 additions and 6 deletions

View File

@ -965,7 +965,7 @@ func (s *IssueService) Search(jql string, options *SearchOptions) ([]Issue, *Res
u += fmt.Sprintf("&startAt=%d", options.StartAt)
}
if options.MaxResults != 0 {
u += fmt.Sprintf("&maxResults=%d", options.MaxResults)
u += fmt.Sprintf("&maxResults=%d", options.MaxResults)
}
if options.Expand != "" {
u += fmt.Sprintf("&expand=%s", options.Expand)
@ -1011,6 +1011,10 @@ func (s *IssueService) SearchPages(jql string, options *SearchOptions, f func(Is
return err
}
if len(issues) == 0 {
return nil
}
for {
for _, issue := range issues {
err = f(issue)