shashank created CAMEL-25657:
--------------------------------
Summary: camel-box - getEnterpriseEvents sends one more request
with stream_position=null when Box answers a chunk without a next stream
position, because box-java-sdk turns a JSON null into the text "null"
Key: CAMEL-25657
URL: https://issues.apache.org/jira/browse/CAMEL-25657
Project: Camel
Issue Type: Bug
Components: camel-box
Reporter: shashank
Assignee: shashank
Follow-up requested in the review of the merged PR
[#27760|https://github.com/apache/camel/pull/27760] (CAMEL-25576).
Since CAMEL-25576, {{BoxEventLogsManager.getEnterpriseEvents}} reads the event
log chunk by chunk and stops on an empty chunk, on the same position again, or
when the next position is null (main 1de5ec5135f8, lines 99-100). The last
check never fires: in box-java-sdk 4.16.4 the {{EventLog}} constructor reads
{{next_stream_position}} with {{isString() ? asString() : toString()}}, so a
JSON null becomes the text {{"null"}} (checked in the class file of 4.16.4).
When a chunk with events comes with a null next position, the manager sends one
more request with {{stream_position=null}}.
What Box answers to that request, and whether the service sends a null next
position at all, was not checked against the service; the reviewer pointed out
that the guard as written cannot fire.
h3. Proposed fix
Stop also when the next position is the text {{"null"}}.
h3. Test
New test {{stopsWhenTheServiceReturnsNoNextPosition}} in
{{BoxEventLogsManagerPagingTest}} (the Box connection answers from memory
through a request interceptor): a chunk of two events whose
{{next_stream_position}} is a JSON null. Without the change: {{a request was
sent at the position "null" ==> expected: <false> but was: <true>}}. camel-box
with the change: 7 tests, 0 failures (the integration tests need a Box account
and were not run).
Affected: main only. On camel-4.23.x, camel-4.22.x and camel-4.18.x
{{getEnterpriseEvents}} reads only the first chunk and does not look at the
next position (read, not run).
_Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)