diff --git a/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java b/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java index 17e2604060..0842ff270c 100644 --- a/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java +++ b/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java @@ -142,25 +142,29 @@ public class ReactorResourceFactory implements InitializingBean, DisposableBean @Override public void destroy() { - - try { - ConnectionProvider provider = this.connectionProvider; - if (provider != null) { - provider.dispose(); - } - } - catch (Throwable ex) { - // ignore + if (this.globalResources) { + HttpResources.disposeLoopsAndConnections(); } + else { + try { + ConnectionProvider provider = this.connectionProvider; + if (provider != null) { + provider.dispose(); + } + } + catch (Throwable ex) { + // ignore + } - try { - LoopResources resources = this.loopResources; - if (resources != null) { - resources.dispose(); + try { + LoopResources resources = this.loopResources; + if (resources != null) { + resources.dispose(); + } + } + catch (Throwable ex) { + // ignore } - } - catch (Throwable ex) { - // ignore } }