allthingssecurity opened a new pull request, #26775: URL: https://github.com/apache/camel/pull/26775
# Description [CAMEL-24928](https://issues.apache.org/jira/browse/CAMEL-24928) With `throttle(0).asyncDelayed()` (total requests mode), or a header-driven rate that evaluates to 0, the exchange failed with a `NullPointerException`. `TotalRequestsThrottler.processAsynchronously` called `throttlingState.peek().getDelay(...)`, and `peek()` returns `null` when no permit is queued. The other three modes wait instead. This change: when `peek()` returns `null`, the exchange is scheduled to try again after one time period. Tests: new `ThrottlerAsyncDelayedNoPermitTest`. The max requests expression returns 0 first and 1 afterwards, with `timePeriodMillis(100).asyncDelayed()`. The exchange must complete without an exception and reach the mock. Without the fix it fails with the `NullPointerException` (`... because the return value of "...ThrottlingState.peek()" is null`). With the fix it passes. `*Throttl*`: 0 failures. Note: with a constant rate of 0, the retried exchange then waits like in the other modes, holding a thread of the throttler pool while the rate is 0 (existing behaviour of that path). # 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 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. -- 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]
