shashank created CAMEL-27339:
--------------------------------

             Summary: camel-jms, camel-sjms - a request that passed the running 
check before the producer stopped creates a reply manager after the stop, which 
is never stopped
                 Key: CAMEL-27339
                 URL: https://issues.apache.org/jira/browse/CAMEL-27339
             Project: Camel
          Issue Type: Bug
          Components: camel-jms, camel-sjms
            Reporter: shashank
            Assignee: shashank


h3. What happens

{{JmsProducer.process}} and {{SjmsProducer.process}} check {{isRunAllowed()}} 
and then call {{initReplyManager()}} for an InOut exchange. The stop does not 
wait for a request between the two: {{doStop}} stops the reply manager and sets 
{{started=false}}. A request that passed the check before the stop then finds 
{{started=false}}, takes the producer's lock (the same lock 
{{BaseService.stop}} holds, so it waits for the stop to end) and creates and 
starts a new reply manager for the stopped producer: a JMS connection and 
listener (a temporary queue by default), a timeout checker thread and an 
onTimeout thread pool. Nothing stops it. If the producer is started again, the 
next request finds {{started=true}} and uses that reply manager, and the next 
stop stops it, so the leak lasts until then; a producer that is not started 
again (a removed route, a stopped {{ProducerTemplate}}) leaks it for good.

h3. How to reproduce

Hold the request where it reads the {{CamelJmsDestinationName}} header (after 
the running check, before {{initReplyManager}}), stop the producer, and let the 
request continue: a reply manager is created after the stop.

Found with a TLA+ model of the reply manager and the producer stop.

h3. Fix

{{initReplyManager}} checks {{isRunAllowed()}} again under the producer's lock 
and fails the request with {{RejectedExecutionException}}, as {{process}} does 
for a stopped producer, instead of creating a reply manager. Independent of 
CAMEL-27321 (every request completes when the reply manager stops), which does 
not touch {{initReplyManager}}.

_Filed with Claude Code on behalf of allthingssecurity._



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

Reply via email to