[ 
https://issues.apache.org/jira/browse/CAMEL-25943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18132239#comment-18132239
 ] 

Claus Ibsen commented on CAMEL-25943:
-------------------------------------

Fixed by https://github.com/apache/camel/pull/28469, merged to main as 
e48face394f190f43df2bba2a4190c1badaeee93 (Camel 4.24.0).

_Claude Code on behalf of davsclaus_

> camel-jira - a consumer with maxResults 0 or less repeats the same search 
> forever on Jira Server / Data Center
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-25943
>                 URL: https://issues.apache.org/jira/browse/CAMEL-25943
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jira
>            Reporter: shashank
>            Assignee: shashank
>            Priority: Major
>             Fix For: 4.24.0
>
>
> {{AbstractJiraConsumer.getIssues}} says that {{maxResults}} is ignored when 
> it is 0 or less, but it first does {{if (maxResults < maxPerQuery) 
> maxPerQuery = maxResults;}} (main 9f839f4bcc9d), so the page size of the 
> search becomes 0 (or negative). On Jira Server / Data Center the loop then 
> asks for a page of 0 issues at {{startAt=0}}, gets no issue and the total, 
> and moves on with {{start += 0}}. None of the exit conditions holds while the 
> search finds an issue ({{maxPerQuery >= total}}, {{start >= total}}, 
> {{maxResults > 0 && ...}}), so the consumer sends the same search request in 
> a tight loop and never returns:
> * {{watchUpdates}} and {{newComments}} read the issues in {{doStart}}: the 
> route never finishes starting, and the CamelContext startup hangs;
> * {{newIssues}} hangs in its first poll when the JQL found no issue at 
> startup (no latest issue yet, so it searches with {{getIssues(jql)}});
> * a negative {{maxResults}} moves the start index backwards.
> The Jira server is called as fast as the consumer thread can go. Claus Ibsen 
> pointed at the line in the review of #28198 (CAMEL-25806), which made the 
> newIssues consumer page through all new issues and already guards its own 
> page size against {{maxResults <= 0}}; the shared {{getIssues}} was not 
> changed there.
> *Fix*: lower the page size only for {{maxResults > 0}} ({{if (maxResults > 0 
> && maxResults < maxPerQuery)}}). The Jira Cloud path gets the same page size 
> of 50 then, instead of 0.
> *Test*: new {{WatchUpdatesConsumerMaxResultsZeroTest}}: a watchUpdates route 
> with {{maxResults=0}} and 60 issues, with a search fake that returns at most 
> {{maxResults}} issues from {{startAt}} and the total, as Jira Server does 
> ({{maxResults=0}} returns only the total). It throws when the same 
> {{startAt}} is asked for more than 10 times in a row. On main the route does 
> not start: {{FailedToStartRouteException: ... The search is repeated at 
> startAt 0}}. With the fix the change of an issue on the second page is 
> routed. camel-jira unit tests with the fix: 63 run, 0 failures.
> *How it was found*: Claus Ibsen's review comment on #28198, confirmed by 
> reading {{getIssues}} on main and by the JUnit test above.
> *Affected*: main, camel-4.23.x, camel-4.22.x, camel-4.18.x, camel-4.14.x and 
> camel-4.8.x (the same line and loop; read, not run).
> _Filed with Claude Code on behalf of allthingssecurity._



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to