vishesh92 commented on code in PR #9661:
URL: https://github.com/apache/cloudstack/pull/9661#discussion_r1756243232


##########
server/src/main/java/com/cloud/api/query/QueryManagerImpl.java:
##########
@@ -818,8 +818,14 @@ private Pair<List<EventJoinVO>, Integer> 
searchForEventsInternal(ListEventsCmd c
         Integer count = eventIdPage.second();
         Long[] idArray = eventIdPage.first().toArray(new Long[0]);
 
-        if (count == 0) {
-            return new Pair<>(new ArrayList<>(), count);
+        /**
+         * Need to check array empty, because {@link 
com.cloud.utils.db.GenericDaoBase#searchAndCount(SearchCriteria, Filter, 
boolean)}
+         * makes two calls: first to get objects and second to get count.
+         * List events has start date filter, there is highly possible cause 
where no objects loaded
+         * and next millisecond new event added and finally we ended up with 
count = 1 and no ids.
+         */
+        if (count == 0 || idArray.length < 1) {
+            count = 0;

Review Comment:
   ```suggestion
               return new Pair<>(new ArrayList<>(), 0);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to