shashank created CAMEL-27588:
--------------------------------
Summary: camel-jms - a temporary reply queue refresh that races
the consumer's resolve leaves replyTo null for good, and every InOut request
fails until the next connection failure
Key: CAMEL-27588
URL: https://issues.apache.org/jira/browse/CAMEL-27588
Project: Camel
Issue Type: Bug
Components: camel-jms
Reporter: shashank
Assignee: shashank
Fix For: 4.24.0
h3. What happens
When the connection of the reply listener container fails, the exception
listener calls {{scheduleRefresh}} of the temporary reply queue resolver in
{{TemporaryQueueReplyManager}}. It bumps the refresh generation and then sets
{{replyTo}} to null, without the resolver's lock. A consumer of the listener
container recovers from the same failure on its own thread and resolves its
destination: it sees the refresh is pending, takes the new generation, creates
a new temporary queue and publishes it ({{setReplyTo}}, published generation =
new generation).
If that resolve runs between the two statements of {{scheduleRefresh}}, the
late {{replyTo = null}} overwrites the queue that was just published. Then:
* no refresh is pending any more, so {{triggerReplyDestinationRecovery}} does
nothing;
* the resolver keeps returning its cached queue without publishing it again;
* every InOut request waits the whole {{getReplyTo}} budget (200 x 100 ms by
default) and fails with "Failed to resolve replyTo destination".
This lasts until another connection failure. The listener container is running
and reports no error.
The window is two statements wide, so it is rare, but when it happens
request-reply over the temporary queue stops working and does not heal on its
own.
h3. How to reproduce
Call {{resolveDestinationName}} on the resolver (as the consumer does) while
the exception listener thread is paused right after it took the new generation
in {{scheduleRefresh}}, then let it finish: {{replyTo}} is null and no refresh
is pending.
Found with a TLA+ model of the refresh generations, the consumers' resolve and
the recovery task (invariant: when no refresh is pending, replyTo is the
resolver's queue; liveness: the reply destination becomes usable again).
h3. Fix
{{scheduleRefresh}} clears {{replyTo}} before it bumps the generation. A
consumer can only publish the new generation after it has seen the bump, so its
publish comes after the null write and wins. No lock is added to the exception
listener path.
camel-sjms is not affected: its {{scheduleRefresh}} only sets a flag and does
not clear {{replyTo}}.
_Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)