allthingssecurity opened a new pull request, #27760:
URL: https://github.com/apache/camel/pull/27760

   # Description
   
   [CAMEL-25576](https://issues.apache.org/jira/browse/CAMEL-25576)
   
   `BoxEventLogsManager.getEnterpriseEvents` (the 
`box:event-logs/getEnterpriseEvents` producer) sends one request and returns 
the events of that response. An `EventLog` of the Box SDK is one chunk of the 
event log: `EnterpriseEventsRequest` asks for at most 500 events (box-java-sdk 
4.16.4), and the response carries `getNextStreamPosition()` for the next chunk. 
The manager does not read that position and does not return it either.
   
   So with more than 500 events between `after` and `before` the caller gets 
the first 500 and cannot ask for the rest: the `position` parameter needs a 
stream position that only the dropped `EventLog` had. Nothing is logged. The 
javadoc of the method says "A list of all the events that met the given 
criteria".
   
   This change: the manager reads on from the next stream position until a 
chunk is empty, which is the end of the events within bounds. It also stops 
when the service returns no next position or the position it was asked for. The 
events are collected in a `LinkedHashSet` (`BoxResource.equals` compares the 
id), so an event that the service returns in two chunks is kept once, in the 
order of the service. The signature is unchanged; the javadoc of the return 
value now says that the log is read chunk by chunk and kept in memory.
   
   Cost: one request per chunk of 500 events and one more that finds the end, 
so two requests where there was one when everything fits in one chunk. I end 
the loop on an empty chunk and not on a chunk shorter than the limit because I 
could not confirm that a short chunk always means the end. A wide `after` / 
`before` window now returns every event in one list, with that many requests 
and more memory; the loop has no limit of its own on the number of chunks. The 
upgrade note and the javadoc say to narrow the window for a large event log.
   
   Behaviour change, with an entry in the 4.24 upgrade guide 
(`camel-4x-upgrade-guide-4_24.adoc`). That file is not on main (c3829069cb72), 
so this PR creates it with the header of the 4_23 guide and adds it to the list 
in `camel-4x-upgrade-guide.adoc`.
   
   Tests:
   - New `BoxEventLogsManagerPagingTest` (3 tests) in camel-box-component. A 
real `BoxAPIConnection` gets a `RequestInterceptor` that answers the events 
request from memory like the service (at most 500 events from the requested 
`stream_position`, and `next_stream_position`), so the SDK parses real 
responses.
   - Without the change all 3 fail: `all the events within bounds, not only the 
first chunk ==> expected: <1200> but was: <500>`; with a start position of 100, 
500 events instead of 1100; and `expected: <2> but was: <1>` requests in the 
test of the loop end (a response that repeats the position it was asked for; 
the events returned twice are kept once).
   - With the change, the camel-box-api and camel-box-component unit tests 
pass: 6 tests, 0 failures. The integration tests need a Box account and were 
not run; nothing was run against Box.
   
   Found with a Lean 4 model of a position-paged service: the event log is a 
list, a response is a `take` / `drop` slice of it and the position after it. 
Property: the result is the log from the position of the caller to its end, 
every event once and in order. Counterexample for main: with chunks of two, 
`[1, 2, 3]` gives `[1, 2]`. In the model, reading chunk after chunk returns the 
list from the start position to its end, and the same as main when the events 
fit in one chunk. The model says nothing about the real service. I then 
reproduced it with the real class.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
     (I built and tested the two affected modules, including the formatter and 
import-sort plugins. I did not run the full root build.)
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
     This PR was prepared with Claude Code (Claude Opus 5.5). The commit 
carries a `Co-Authored-By` trailer.
   
   _Claude Code on behalf of allthingssecurity_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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