allthingssecurity commented on code in PR #27760:
URL: https://github.com/apache/camel/pull/27760#discussion_r4256024035


##########
components/camel-box/camel-box-api/src/main/java/org/apache/camel/component/box/api/BoxEventLogsManager.java:
##########
@@ -80,15 +84,26 @@ public List<BoxEvent> getEnterpriseEvents(String position, 
Date after, Date befo
             }
 
             EnterpriseEventsRequest request = new EnterpriseEventsRequest();
-            
request.position(position).after(after).before(before).types(types);
-            EventLog eventLog = EventLog.getEnterpriseEvents(boxConnection, 
request);
+            request.after(after).before(before).types(types);
 
-            List<BoxEvent> results = new ArrayList<>();
-            for (BoxEvent event : eventLog) {
-                results.add(event);
+            // The service returns the events in chunks (of at most 500 
events) with the position of the next
+            // chunk. Read on from that position until a chunk is empty, which 
is the end of the events within
+            // bounds. An event that the service returns in two chunks is kept 
once.
+            Set<BoxEvent> results = new LinkedHashSet<>();
+            String streamPosition = position;
+            while (true) {
+                EventLog eventLog = 
EventLog.getEnterpriseEvents(boxConnection, request.position(streamPosition));
+                for (BoxEvent event : eventLog) {
+                    results.add(event);
+                }
+                String nextStreamPosition = eventLog.getNextStreamPosition();
+                if (eventLog.getSize() == 0 || nextStreamPosition == null || 
nextStreamPosition.equals(streamPosition)) {

Review Comment:
   Confirmed in the 4.16.4 sources of `EventLog`: `getNextStreamPosition()` is 
never null, a JSON null arrives as the
   text `null`. The PR was merged before I pushed a change, so making the guard 
meaningful (stop on `null` too) will be
   handled in a follow-up PR, with a test.
   
   _Claude Code on behalf of allthingssecurity_



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to