[
https://issues.apache.org/jira/browse/CAMEL-27537?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Work on CAMEL-27537 started by shashank.
----------------------------------------
> camel-xmpp - a route stopped while the consumer's delayed start waits for the
> account's connection is started again by that delayed start, and keeps the
> connection open
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27537
> URL: https://issues.apache.org/jira/browse/CAMEL-27537
> Project: Camel
> Issue Type: Bug
> Components: camel-xmpp
> Reporter: shashank
> Assignee: shashank
> Priority: Major
>
> h3. What happens
> With {{testConnectionOnStartup=false}}, the delayed start of the consumer
> gets the account's shared connection: it registers itself as a user of the
> connection, then waits for the account's lock, which another consumer or
> producer of the same account holds while it connects or logs in (for example
> to a slow server). {{ReentrantLock.lock()}} does not react to an interrupt.
> When the route is stopped while the delayed start waits there, {{doStop}}
> shuts the executor down (which does not wait for the running task) and has no
> connection to release yet, as the {{connection}} field is still null. When
> the delayed start then gets the lock, it carries on with the stopped consumer:
> * a chat consumer finishes its start: it registers its chat listener and
> connection listener, and creates a new executor for its connection monitor
> (the field was cleared by the stop). The stopped route's consumer keeps
> routing incoming chat messages into the route;
> * a room consumer is interrupted in the room join and its start fails, but it
> stays a user of the connection.
> Either way the stopped consumer stays a user of the account's connection, so
> the connection is not closed when the other users release it, and the session
> stays logged in on the server until the component stops.
> h3. How to reproduce
> A chat consumer with {{testConnectionOnStartup=false}} and the server down at
> start. When the server is up, a second user of the account holds the
> account's lock until the delayed start waits for it; then the route is
> stopped and the lock released. After the stop the route is Stopped, but the
> consumer has a logged-in connection, the account's connection still has one
> user, the server keeps the session, a chat message sent after the stop is
> routed into the stopped route, and a connectionPoll thread is running. A room
> consumer: the route is Stopped and the connection keeps one user and its
> session.
> Found with a TLA+ model of the consumer's delayed start and stop, and
> reproduced against the real consumer with a small fake XMPP server.
> h3. Fix
> The delayed start checks under a lock that the consumer is not stopping after
> it got the connection and before it listens on it, enters the room or starts
> the connection monitor; if the consumer is stopping it releases the
> connection and ends. A delayed start that fails while the consumer is
> stopping does not schedule another one. {{doStop}} still shuts the executor
> down first (which cancels a pending delayed start and interrupts a running
> one), then takes the same lock, so it waits for a delayed start that is
> subscribing and shuts down the executor that start created.
> Not changed here: a restart of the route while the old delayed start is still
> connecting can let the failure path of the old attempt release the new
> start's use of the connection (the users set holds the consumer once); that
> needs a change in the shared connection's bookkeeping.
> _Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)