allthingssecurity commented on PR #30304:
URL: https://github.com/apache/camel/pull/30304#issuecomment-6973209231

   Thanks Claus, all good points.
   
   - **[Important] rejected path completing twice:** fixed in c61883f. 
`AsyncCall.rejected()` now returns the result of the remove, and both throttler 
catch blocks return `false` when `doShutdown` already claimed the call (it has 
called `callback.done(false)`). In `DelayProcessorSupport` the catch block 
returns `false` before the decrement when `scheduledCalls.remove(call)` is 
false, so `delayedCount` is not decremented twice either. 
`AsyncDelayedShutdownRaceTest` drives this deterministically with a pool that 
shuts the EIP down right before it takes the task and then rejects it (Abort 
policy), for the Delay and both throttler modes. Without the change the 
rejected path completes the exchange a second time and `process` returns `true` 
after `doShutdown` already called `done(false)`; with it the callback is called 
once and `delayedCount` ends at 0.
   - **[Suggestion] late window with CallerRuns:** done in the same commit, as 
you suggested. After a successful `schedule` / `submit`, if the EIP's own pool 
is shut down and the call can still be claimed, the exchange is failed in the 
calling thread with a `RouteStoppingException` and `done(true)`. I limited it 
to the pool the EIP owns, as only that one is shut down with `shutdownNow` 
here. Three more cases in `AsyncDelayedShutdownRaceTest` cover it (the EIP is 
shut down first, then the exchange is handed over to a pool with 
`CallerRunsPolicy`): without the change the callback is never called.
   - **[Suggestion] Threads EIP with instrumented pools:** I kept this PR small 
and added a comment in `ThreadsProcessor.doShutdown` that a factory that wraps 
the tasks hands back its own wrappers, which are not `Rejectable`, so those 
exchanges are not failed there. Using the claim set in the Threads EIP too can 
be a follow-up.
   - **[Question] await manager order:** yes. `AbstractCamelContext.doStop` 
shuts down the await manager (which sets a `RejectedExecutionException` on the 
exchange and counts the latch down) before the route services. A later 
`failScheduledCalls` / `failAsyncCalls` then counts down a latch that is 
already at 0 and sets the `RouteStoppingException` on an exchange whose caller 
was released. That is the same as main does for the tasks that are running at 
that moment, so I left it.
   - **[Nit]** `assertTrue(busy.await(...))`: done.
   
   Targeted runs: the delay, throttle, threads, thread pool, shutdown and 
remove route tests of camel-core pass (281 run, 0 failures, 4 skipped by their 
own conditions), the throttler, delayer and throttling policy tests of 
camel-management pass (13 run), and the two test classes pass 10 times in one 
JVM (110/110). With the main files reverted, the six new tests fail.
   
   _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