Skip to content

Commit 709b185

Browse files
committed
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
1 parent 89e2caa commit 709b185

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

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

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -142,25 +142,29 @@ public void afterPropertiesSet() throws Exception {
142142

143143
@Override
144144
public void destroy() {
145-
146-
try {
147-
ConnectionProvider provider = this.connectionProvider;
148-
if (provider != null) {
149-
provider.dispose();
150-
}
151-
}
152-
catch (Throwable ex) {
153-
// ignore
145+
if (this.globalResources) {
146+
HttpResources.disposeLoopsAndConnections();
154147
}
148+
else {
149+
try {
150+
ConnectionProvider provider = this.connectionProvider;
151+
if (provider != null) {
152+
provider.dispose();
153+
}
154+
}
155+
catch (Throwable ex) {
156+
// ignore
157+
}
155158

156-
try {
157-
LoopResources resources = this.loopResources;
158-
if (resources != null) {
159-
resources.dispose();
159+
try {
160+
LoopResources resources = this.loopResources;
161+
if (resources != null) {
162+
resources.dispose();
163+
}
164+
}
165+
catch (Throwable ex) {
166+
// ignore
160167
}
161-
}
162-
catch (Throwable ex) {
163-
// ignore
164168
}
165169
}
166170

0 commit comments

Comments
 (0)