Skip to content

Conversation

artembilan
Copy link
Member

Fixes: #9430

When CachingClientConnectionFactory is used in combination of Tcp.outboundAdapter() & Tcp.inboundAdapter(), the connection is not released back to the cache because CachingClientConnectionFactory does not store created connections into its connections property. So, when TcpReceivingChannelAdapter calls this.clientConnectionFactory.closeConnection(connectionId); it returned immediately because there is nothing to remove from the this.connections

  • Add protected removeConnection() in the AbstractConnectionFactory and override it in the CachingClientConnectionFactory with delegation to the this.targetConnectionFactory
  • Demonstrate the problem in the new IpIntegrationTests.allRepliesAreReceivedViaLimitedCachingConnectionFactory() test and ensure that all 27 letters from English alphabet are sent to the server and received in uppercase while size of the CachingClientConnectionFactory is only 10

Auto-cherry-pick to 6.3.x & 6.2.x

… adapters

Fixes: spring-projects#9430

When `CachingClientConnectionFactory` is used in combination of
`Tcp.outboundAdapter()` & `Tcp.inboundAdapter()`, the connection is not released
back to the cache because `CachingClientConnectionFactory` does not store
created connections into its `connections` property.
So, when `TcpReceivingChannelAdapter` calls `this.clientConnectionFactory.closeConnection(connectionId);`
it returned immediately because there is nothing to remove from the `this.connections`

* Add `protected removeConnection()` in the `AbstractConnectionFactory`
and override it in the `CachingClientConnectionFactory` with delegation to the `this.targetConnectionFactory`
* Demonstrate the problem in the new `IpIntegrationTests.allRepliesAreReceivedViaLimitedCachingConnectionFactory()` test
and ensure that all 27 letters from English alphabet are sent to the server and received in uppercase
while size of the `CachingClientConnectionFactory` is only `10`

**Auto-cherry-pick to `6.3.x` & `6.2.x`**
@artembilan artembilan requested a review from sobychacko August 29, 2024 21:32
@artembilan artembilan merged commit dc02dec into spring-projects:main Aug 30, 2024
3 checks passed
spring-builds pushed a commit that referenced this pull request Aug 30, 2024
Fixes: #9430

When `CachingClientConnectionFactory` is used in combination of
`Tcp.outboundAdapter()` & `Tcp.inboundAdapter()`, the connection is not released
back to the cache because `CachingClientConnectionFactory` does not store
created connections into its `connections` property.
So, when `TcpReceivingChannelAdapter` calls `this.clientConnectionFactory.closeConnection(connectionId);`
it returned immediately because there is nothing to remove from the `this.connections`

* Add `protected removeConnection()` in the `AbstractConnectionFactory`
and override it in the `CachingClientConnectionFactory` with delegation to the `this.targetConnectionFactory`
* Demonstrate the problem in the new `IpIntegrationTests.allRepliesAreReceivedViaLimitedCachingConnectionFactory()` test
and ensure that all 27 letters from English alphabet are sent to the server and received in uppercase
while size of the `CachingClientConnectionFactory` is only `10`

(cherry picked from commit dc02dec)
spring-builds pushed a commit that referenced this pull request Aug 30, 2024
Fixes: #9430

When `CachingClientConnectionFactory` is used in combination of
`Tcp.outboundAdapter()` & `Tcp.inboundAdapter()`, the connection is not released
back to the cache because `CachingClientConnectionFactory` does not store
created connections into its `connections` property.
So, when `TcpReceivingChannelAdapter` calls `this.clientConnectionFactory.closeConnection(connectionId);`
it returned immediately because there is nothing to remove from the `this.connections`

* Add `protected removeConnection()` in the `AbstractConnectionFactory`
and override it in the `CachingClientConnectionFactory` with delegation to the `this.targetConnectionFactory`
* Demonstrate the problem in the new `IpIntegrationTests.allRepliesAreReceivedViaLimitedCachingConnectionFactory()` test
and ensure that all 27 letters from English alphabet are sent to the server and received in uppercase
while size of the `CachingClientConnectionFactory` is only `10`

(cherry picked from commit dc02dec)
@artembilan artembilan deleted the GH-9430 branch August 30, 2024 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TCP/IP: The cached connections are not freed when used with collaborating channel adapters on the client side
2 participants