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

   # Description
   
   [CAMEL-26906](https://issues.apache.org/jira/browse/CAMEL-26906)
   
   Follow-up of #29525 (CAMEL-26741, an `Error` of a processor fails the 
exchange), the sibling named in #29785 (CAMEL-26881, the purge task of the 
Aggregate EIP). The same timer was fixed in #29121 (CAMEL-26537) for a listener 
added or removed while it runs; this is the other way it stopped for good.
   
   `TimerListenerManager` (camel-support) calls its listeners from a task 
scheduled with `scheduleAtFixedRate`, and caught only `Exception` around each 
`onTimer`. An `Error` that is not a `VirtualMachineError` (such as a 
`NoClassDefFoundError` or an `AssertionError`) thrown by one listener ended the 
scheduled task: the executor keeps the `Error` in the `ScheduledFuture`, which 
nothing reads, so nothing was logged, and no listener was called again until 
the CamelContext was restarted. Two services extend it:
   - `DefaultPeriodTaskScheduler`, which runs the tasks scheduled with 
`schedulePeriodTask` on the timer thread: the secret refresh tasks of the AWS, 
GCP, Azure Key Vault and Hashicorp vaults and of Spring Cloud Config, the lock 
renewal of the camel-azure-servicebus consumer (`PEEK_LOCK`), and the clipboard 
reload of camel-jbang. An `Error` of one task stopped all of them: for example 
an `Error` of a vault refresh task also stopped the lock renewal of the Service 
Bus consumers, so the locks of long-running exchanges expired and their 
messages were delivered again;
   - `ManagedLoadTimer`, which updates the load statistics of JMX, when they 
are enabled (`loadStatisticsEnabled`, off by default).
   
   The tasks scheduled with `scheduledTask` (the Kubernetes secrets and config 
maps refresh, IBM Secrets Manager) are not on this path: the timer only submits 
them once to their own thread, and this PR does not change them.
   
   Change: `TimerListenerManager.run` also catches `Error` around each 
listener, logs it at WARN and goes on (an exception stays logged at DEBUG, as 
before; an `Error` is logged at WARN as it stopped the timer without a log line 
before). A `VirtualMachineError` is thrown on as before, and still ends the 
task. A periodic task that keeps failing logs one WARN per its own period (the 
period task scheduler restarts the period before it runs the task), not one per 
second. This is the same pattern as the purge task of `DefaultTimeoutMap` in 
#29785, which this PR does not touch.
   
   Tests:
   - `TimerListenerManagerTest`: + `testErrorOfAListenerKeepsTheTimerRunning`, 
the first of two listeners throws an `AssertionError` in its first call: the 
second one is called 3 times, and the first one is called again; + 
`testExceptionOfAListenerKeepsTheTimerRunning`, the same with an 
`IllegalStateException` (control, passes on main);
   - `PeriodTaskSchedulerTest`: + 
`testSchedulerKeepsRunningAfterAnErrorOfATask`, a periodic task throws an 
`AssertionError` in its first run: another periodic task keeps running, and the 
failing task runs again.
   
   Without the change the two `Error` tests fail on main (no listener or task 
is called after the `Error`); with it they pass, 20 runs of both classes in one 
JVM pass (220/220), and the camel-core tests pass (9219 run, 0 failures; 12 
errors: 11 `DumpModelAsYaml*`/`DumpModel*` tests that fail with 
`NoClassDefFoundError: OgnlExpression` from a stale camel-yaml-io jar in my 
local repository, and `EventNotifierExchangeSentTest.testExchangeWireTap`, a 1 
second timing check that passes on rerun, 20 runs 60/60).
   
   No documentation or upgrade guide change: nothing changes for an exception 
or a `VirtualMachineError`, and for another `Error` the only difference is that 
it is logged and the timer goes on, where before it stopped without a log line.
   
   # 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): 
[CAMEL-26906](https://issues.apache.org/jira/browse/CAMEL-26906).
   
   # 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 the core modules with the formatter and import-sort plugins and 
ran the camel-core tests. 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.
   
   _Claude Code on behalf of allthingssecurity_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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