Browse Source

Clear global resources reference from HttpResources

When used as global Netty resources, ReactorResourceFactory creates and
sets those resources on Reactor's HttpResources directly.

When that ReactorResourceFactory bean is destroyed, those resources are
disposed but HttpResources still holds a reference to those and may try
to use them again.

This commit uses HttpResources to clear those resources and its
references to it, when the ReactorResourceFactory is treating those as
global.

Issue: SPR-17199
pull/1936/head
Brian Clozel 6 years ago
parent
commit
709b185177
  1. 36
      spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java

36
spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java

@ -142,25 +142,29 @@ public class ReactorResourceFactory implements InitializingBean, DisposableBean @@ -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
}
}

Loading…
Cancel
Save