Details
-
Bug
-
Status: Resolved
-
Critical
-
Resolution: Fixed
-
4.0.0, 4.0.1, 4.0.2, 4.1.0, 4.2.0
-
None
-
Patch Available
-
Unknown
-
Important
Description
as already posted on the dev mailing list the DefaultProducerCache can return a wrong ProducerTemplate under high concurrency load which leads to misrouted exchanges and therefor errors in the application and workflow.
The improvement in the DefaultProducerCache from issue 19058 introduced a severe concurrency issue with that change.
While writing to the "lastUsed" fields in "acquireProducers" is synchronised, so that they are updated together, the read at the beginning of the method is not synchronised at all with the writes and therefor can be read at every time, even between the synced update to the fields which can lead to wrong producer templates being returned under high concurrency load. This then leads to exchanges being delivered to wrong endpoints causing severe malfunctions and errors.
i have created a patch (and also a branch in my forked camel repo) including the fix and a unit test reproduces the problem with returning the wrong producer template for the requested endpoint when accessing from multiple threads