Praveenkumar76 opened a new pull request, #25935:
URL: https://github.com/apache/pulsar/pull/25935

   Fixes apache#25660
   
   ### Motivation
   
   The usage of `java.time.Clock` is currently inconsistent across the broker 
module, with many classes directly relying on `System.currentTimeMillis()` for 
timestamp generation.
   
   As issued in #25660, standardizing timestamp handling through the 
centralized `PulsarService` clock improves consistency across the codebase and 
makes time-dependent behavior easier to control during testing. This also helps 
reduce test flakiness by enabling deterministic time mocking in unit and 
integration tests.
   
   Since there are many occurrences of `System.currentTimeMillis()` across the 
repository, this PR intentionally scopes the change to a limited set of 
broker-related classes to keep the review manageable and minimize the risk of 
unintended side effects.
   
   
   ### Modifications
   
   Replaced direct usages of `System.currentTimeMillis()` with 
`pulsar.getClock().millis()` (or equivalent broker-scoped clock access) in 
selected broker module classes, including:
   
   - Broker service classes
   - Producer and consumer classes
   - Persistent subscription and expiry monitor implementations
   - Schema registry related classes
   - Broker statistics classes
   
   Additional changes:
   
   - Left existing `System.nanoTime()` usages unchanged since they are used for 
monotonic latency measurements rather than wall-clock timestamps
   
   
   ### Verifying this change
   
   This change can be verified as follows:
   
   - Confirmed successful compilation and existing broker tests continue to pass
   - Verified timestamp-related logic now consistently uses the centralized 
broker clock
   - Confirmed no behavioral changes in latency-related code paths using 
`System.nanoTime()`
   
   
   ### Does this pull request potentially affect one of the following parts:
   
   - [ ] Dependencies (add or upgrade a dependency)
   - [ ] The public API
   - [ ] The schema
   - [ ] The default values of configurations
   - [ ] The threading model
   - [ ] The binary protocol
   - [ ] The REST endpoints
   - [ ] The admin CLI options
   - [ ] The metrics
   - [ ] Anything that affects deployment


-- 
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