[ 
https://issues.apache.org/jira/browse/CAMEL-27338?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Work on CAMEL-27338 started by shashank.
----------------------------------------
> camel-netty - a request that fails while it is set up on its pooled channel 
> (before it is sent) never gives the channel back to the producer pool
> -------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27338
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27338
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-netty
>            Reporter: shashank
>            Assignee: shashank
>            Priority: Major
>
> h3. What happens
> {{NettyProducer.processWithConnectedChannel}} sets up the request on the 
> channel it borrowed from the producer pool: the request timeout (from 
> {{CamelNettyRequestTimeout}} or {{requestTimeout}}) and the state of the 
> correlation manager. If that throws, {{ChannelConnectedListener}} completes 
> the exchange with the exception through {{BodyReleaseCallback}}, which does 
> not release the channel: only the {{NettyProducerCallback}} created later 
> releases it. The channel stays borrowed for ever. Triggers: a 
> {{CamelNettyRequestTimeout}} header that is not a number, a request without a 
> correlation id for a {{TimeoutCorrelationManagerSupport}} manager, or a 
> custom pipeline without a {{handler}}.
> With {{producerPoolMaxTotal}} set, the pool runs out after that many failed 
> requests: the next requests wait for a channel ({{producerPoolMaxWait=-1}}, 
> the default: for ever) or fail with {{NoSuchElementException}}.
> h3. How to reproduce
> {{netty:tcp://localhost:port?textline=true&sync=true&producerPoolMaxTotal=1&producerPoolMaxWait=2000}}:
>  send one request with {{CamelNettyRequestTimeout=not a number}}, then a 
> valid request: it fails with {{NoSuchElementException: Timeout waiting for 
> idle object}}.
> Found with a TLA+ model of the netty producer.
> h3. Fix
> When setting up the request fails, the borrowed channel of the producer pool 
> is invalidated (closed and removed from the pool): activating it armed the 
> request timeout, which would otherwise fire on the idle channel, and the 
> pipeline may have been changed. The shared channel of 
> {{producerPoolEnabled=false}} is released as usual. With 
> {{reuseChannel=true}} nothing changes; there the channel is returned by an 
> on-completion that only overrides {{onComplete}}, so a failed exchange never 
> returns it (a separate issue).
> _Filed with Claude Code on behalf of allthingssecurity._



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

Reply via email to