Skip to content

Commit 8ef727b

Browse files
committed
Dispose Existing Connection and Thread Pools
Previously, the DefaultConnectionContext did not cache the connection and thread pools that it used. This meant that new instances of these resources were created when dispose was called, and the originals were never disposed. This change caches those connection and thread pools so that they are properly disposed. [resolves #815]
1 parent dcfb098 commit 8ef727b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/_DefaultConnectionContext.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ public void trust(String host, int port) {
141141
*/
142142
abstract Optional<Duration> getConnectTimeout();
143143

144+
@Value.Derived
145+
Optional<PoolResources> getConnectionPool() {
146+
return Optional.ofNullable(getConnectionPoolSize())
147+
.map(connectionPoolSize -> PoolResources.fixed("cloudfoundry-client", connectionPoolSize));
148+
}
149+
144150
/**
145151
* The {@code SO_KEEPALIVE} value
146152
*/
@@ -195,12 +201,8 @@ Optional<SslCertificateTruster> getSslCertificateTruster() {
195201
*/
196202
abstract Optional<Duration> getSslHandshakeTimeout();
197203

198-
private Optional<PoolResources> getConnectionPool() {
199-
return Optional.ofNullable(getConnectionPoolSize())
200-
.map(connectionPoolSize -> PoolResources.fixed("cloudfoundry-client", connectionPoolSize));
201-
}
202-
203-
private LoopResources getThreadPool() {
204+
@Value.Derived
205+
LoopResources getThreadPool() {
204206
return LoopResources.create("cloudfoundry-client", getThreadPoolSize(), true);
205207
}
206208

0 commit comments

Comments
 (0)