This is an automated email from the ASF dual-hosted git repository.

fmariani pushed a commit to branch camel-4.10.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-4.10.x by this push:
     new 32b7525d07b Reapply "fix(jira): Fix querying issues on jira cloud 
instance (#18513) (#19362)"
32b7525d07b is described below

commit 32b7525d07b5f05593ab33912722c3e13ef016c9
Author: Marco Carletti <[email protected]>
AuthorDate: Tue Sep 30 12:34:15 2025 +0200

    Reapply "fix(jira): Fix querying issues on jira cloud instance (#18513) 
(#19362)"
    
    This reverts commit 426215c3bd142efba24bfb36767f88392180feaf.
---
 .../component/jira/consumer/AbstractJiraConsumer.java | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git 
a/components/camel-jira/src/main/java/org/apache/camel/component/jira/consumer/AbstractJiraConsumer.java
 
b/components/camel-jira/src/main/java/org/apache/camel/component/jira/consumer/AbstractJiraConsumer.java
index 5329a1a64f4..c9210811a5d 100644
--- 
a/components/camel-jira/src/main/java/org/apache/camel/component/jira/consumer/AbstractJiraConsumer.java
+++ 
b/components/camel-jira/src/main/java/org/apache/camel/component/jira/consumer/AbstractJiraConsumer.java
@@ -26,6 +26,7 @@ import com.atlassian.jira.rest.client.api.RestClientException;
 import com.atlassian.jira.rest.client.api.SearchRestClient;
 import com.atlassian.jira.rest.client.api.domain.Issue;
 import com.atlassian.jira.rest.client.api.domain.SearchResult;
+import 
com.atlassian.jira.rest.client.internal.async.AsynchronousCloudSearchRestClient;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePropertyKey;
 import org.apache.camel.Processor;
@@ -125,18 +126,26 @@ public abstract class AbstractJiraConsumer extends 
ScheduledBatchPollingConsumer
         Set<Issue> issues = new LinkedHashSet<>();
         while (true) {
             SearchRestClient searchRestClient = 
endpoint.getClient().getSearchClient();
-            SearchResult searchResult = searchRestClient.searchJql(jql, 
maxPerQuery, start, null).claim();
+            // *navigable should be the default value, but it does not seem to 
be true with 6.0.2 client
+            SearchResult searchResult = searchRestClient.searchJql(jql, 
maxPerQuery, start, Set.of("*navigable")).claim();
 
             for (Issue issue : searchResult.getIssues()) {
                 issues.add(issue);
             }
 
-            // Note: #getTotal == the total # the query would return *without* 
pagination, effectively telling us
+            // Note: the total # the query would return *without* pagination, 
effectively telling us
             // we've reached the end. Also exit early if we're limiting the # 
of results or
             // if total # of returned issues is lower than the actual page 
size.
-            if (maxPerQuery >= searchResult.getTotal() ||
-                    start >= searchResult.getTotal() ||
-                    maxResults > 0 && issues.size() >= maxResults) {
+            int total;
+            if (searchRestClient instanceof AsynchronousCloudSearchRestClient) 
{
+                // calling searchResult.getTotal() on 
AsynchronousCloudSearchRestClient throws an exception:
+                // Total is not available in the Cloud version of the new 
Search API response.
+                // Please use `SearchRestClient.totalCount` instead to fetch 
the estimated count of the issues for a given JQL
+                total = searchRestClient.totalCount(jql).claim().getCount();
+            } else {
+                total = searchResult.getTotal();
+            }
+            if (maxPerQuery >= total || start >= total || maxResults > 0 && 
issues.size() >= maxResults) {
                 break;
             }
 

Reply via email to