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

   # Description
   
   [CAMEL-24927](https://issues.apache.org/jira/browse/CAMEL-24927)
   
   Since `SamplingThrottler` moved to `System.nanoTime()` (CAMEL-20267), 
`timeOfLastExchange` still started at 0. The first exchange only passed once 
`nanoTime` (roughly the time since boot on Linux and macOS) exceeded the sample 
period. So `sample(Duration.ofHours(24))` dropped every message on a machine 
that had been up for less than 24 hours.
   
   This change: a `sampledOnce` flag, guarded by the existing 
`calculationLock`, lets the first exchange through.
   
   Tests: `SamplingThrottlerTest.testFirstExchangeIsSampledWithLongPeriod` 
sends 5 messages to `sample(Duration.ofDays(36500))`, and exactly the first one 
must pass. Without the fix it fails with `mock://result Received message count. 
Expected: <1> but was: <0>`. With the fix, `SamplingThrottlerTest` passes 7/7. 
`*Sampl*,*Throttl*`: 56 tests, 0 failures.
   
   # 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]

Reply via email to