[ 
https://issues.apache.org/jira/browse/CAMEL-26752?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen updated CAMEL-26752:
--------------------------------
    Fix Version/s: 4.24.0

> camel-util - TimeSource: a check against direct clock calls in the moved 
> classes, and a log line for a non-default provider
> ---------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-26752
>                 URL: https://issues.apache.org/jira/browse/CAMEL-26752
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: shashank
>            Assignee: shashank
>            Priority: Minor
>             Fix For: 4.24.0
>
>
> Follow-ups of CAMEL-25911 (apache/camel#28382), as agreed on the dev@ list in 
> the thread "[DISCUSS] An internal time source in camel-util (for 
> deterministic simulation tests)" 
> (https://lists.apache.org/thread/grhr2y5975pqp0rvoschf7d1kff0nwx7).
> *1. A check against direct clock calls.* The core classes that read the clock 
> and sleep through {{TimeSource}} (the redelivery, the delayer, the 
> throttlers, the task classes and their budgets, the shutdown wait loop, 
> {{StopWatch}}, {{MonotonicClock}}, {{BackOffTimerTask}}, 
> {{DefaultTimeoutMap}}, {{ThrottlingExceptionRoutePolicy}}, and the send and 
> step hooks of CAMEL-26331 / CAMEL-26338) have nothing that stops someone from 
> adding a {{System.nanoTime()}} or {{Thread.sleep()}} to them again. Such a 
> call takes that wait out of the virtual time of a deterministic simulation 
> test, and nothing would notice. Camel does not use the forbidden-apis plugin. 
> A test in camel-core scans the sources of an explicit list of these classes 
> (without comments and string literals) and fails on {{System.nanoTime()}}, 
> {{System.currentTimeMillis()}} and {{Thread.sleep}} (also as 
> {{Instant.now()}}, {{TimeUnit.X.sleep}}, a method reference or a static 
> import), saying which {{TimeSource}} method to use instead. The default 
> provider of {{TimeSource}} is the one allowed place.
> *2. A log line for a non-default provider.* The provider is static, so in a 
> shared runtime such as Karaf an installed provider applies to every 
> CamelContext that shares camel-util. {{TimeSource.install}} logs a line at 
> INFO when a provider other than the default is installed, and when the 
> default one is put back, naming the provider class, so it shows up if it ever 
> leaks out of a test harness.
> *3. Javadoc and docs.* {{TimeSource}} stays internal. The Javadoc, 
> test-dst.adoc and the chaos design page say that it is not an API for 
> components: a component gets virtual time through the core classes it already 
> uses, and camel-chaos is the one exception.
> No behaviour change apart from the new INFO lines, which only a test harness 
> triggers (camel-test-dst logs two per seed).
> _Filed with Claude Code on behalf of allthingssecurity._



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to