allthingssecurity opened a new pull request, #30313: URL: https://github.com/apache/camel/pull/30313
# Description [CAMEL-26954](https://issues.apache.org/jira/browse/CAMEL-26954) `DefaultBacklogDebugger` keeps one suspended exchange per node (`suspendedBreakpoints` and `suspendedBreakpointMessages`, keyed by node id). Since CAMEL-26883 a `NodeBreakpoint` registers with `putIfAbsent` and removes only its own entry, but the single-step breakpoint (`StepBreakpoint.beforeProcess` and its `doCompleted`) still used `put`. So when exchange E2 is suspended at node N by a node breakpoint, and exchange E1 is single-stepped into N (the debugger runs the node breakpoints for the exchanges that are not single-stepped, so both can be at N), the step of E1 replaced the entry and the message of E2. The debugger then showed only E1 at N, a resume or step of N continued E1 only, and E2 waited unseen until the fallback timeout (300 seconds by default). The JIRA leaves the way to fix it open (keep E2 and let the step of E1 wait, or key the suspended exchanges by node and exchange id). This PR takes the first one, as it keeps the one-exchange-per-node model and the debugger API (`resumeBreakpoint(nodeId)`, `getSuspendedBreakpointNodeIds()`, the message per node) as they are. Keying by exchange id would change what those methods mean. Change, in `DefaultBacklogDebugger.StepBreakpoint` (the two copies of the suspend code are now one method, `suspendStep`): - a step registers its exchange at the node with `putIfAbsent`. If another exchange is suspended there, the step waits until that exchange is no longer suspended at the node (it is resumed or stepped on, its breakpoint is removed, or it times out), then registers. It checks every 100 ms, as a timed-out node breakpoint removes its entry without a resume; - the message of the step is published only while its exchange is the one at the node (the same `compute` as the node breakpoint); - if the step waited and in the meantime the single step of its exchange ended (a resume that is not a step, `resumeAll`) or the debugger was disabled, the exchange continues without suspending at the node, as it would have done if it had not waited; - the wait is bounded by the fallback timeout; after it the exchange continues with a WARN log, as on the other timeouts. What the user sees in the scenario: N shows E2. A `step` (it continues every suspended exchange) continues E2, and E1 is then suspended at N as the next step. A `resumeBreakpoint(N)` continues E2 and ends the single step of E1, which continues. Nothing changes when no other exchange is at the node. Tests, new `BacklogDebuggerStepIntoSuspendedNodeTest` (camel-management, next to `BacklogDebuggerResumedBeforeSuspendTest`), route `seda:start?concurrentConsumers=2` with nodes foo and bar: - `testStepIntoNodeWithSuspendedExchange`: E2 is suspended at bar; E1 is suspended at foo and stepped from there; once E1 reached bar (the debug counter moved) the debugger must still show E2 at bar for 500 ms. A `step` then continues E2, E1 must be shown suspended at bar, and after a resume both reach the end; - `testResumeWhileTheStepWaitsForTheNode`: the same start, then `resumeBreakpoint("bar")`: both exchanges must complete within 10 seconds and nothing is left suspended. Without the change both fail at the check that bar still shows E2: E1's exchange id replaced it. With the change the camel-management tests pass (489 run, 0 failures) except the four YAML dump tests (`ManagedCamelContextDumpRoutesAsYamlTest`, `ManagedRouteAndContextEdgeCasesTest.testDumpWithoutGeneratedIds`), which fail in my offline build with a `NoClassDefFoundError` of `OgnlExpression` from a cached camel-yaml-io snapshot, the same way on main without this change, and do not touch the debugger. The debugger tests (`BacklogDebugger*Test`, `*Debugger*Test`) are part of that run and pass, and the new test class passes 20 times in one JVM (40 of 40). No documentation or upgrade guide change (developer tooling; the debugger API is unchanged). # 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): [CAMEL-26954](https://issues.apache.org/jira/browse/CAMEL-26954). # 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 the core modules and camel-management with the formatter and import-sort plugins and ran the tests named above. 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]
