From ca2b2f5533a15dd37eb89ed46c8214a525b4cdc8 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Tue, 17 Sep 2019 09:49:05 +0200 Subject: [PATCH] Wait for complete disposal of Reactor Netty resources Fixes gh-23631 --- .../http/client/reactive/ReactorResourceFactory.java | 8 ++++---- .../http/client/reactive/ReactorResourceFactoryTests.java | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) 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 0cdd16fe3e7..fdfd1a78d8f 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -181,13 +181,13 @@ public class ReactorResourceFactory implements InitializingBean, DisposableBean @Override public void destroy() { if (this.useGlobalResources) { - HttpResources.disposeLoopsAndConnections(); + HttpResources.disposeLoopsAndConnectionsLater().block(); } else { try { ConnectionProvider provider = this.connectionProvider; if (provider != null && this.manageConnectionProvider) { - provider.dispose(); + provider.disposeLater().block(); } } catch (Throwable ex) { @@ -197,7 +197,7 @@ public class ReactorResourceFactory implements InitializingBean, DisposableBean try { LoopResources resources = this.loopResources; if (resources != null && this.manageLoopResources) { - resources.dispose(); + resources.disposeLater().block(); } } catch (Throwable ex) { diff --git a/spring-web/src/test/java/org/springframework/http/client/reactive/ReactorResourceFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/reactive/ReactorResourceFactoryTests.java index cc8bee4b72d..f5e64f871b3 100644 --- a/spring-web/src/test/java/org/springframework/http/client/reactive/ReactorResourceFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/reactive/ReactorResourceFactoryTests.java @@ -107,8 +107,8 @@ public class ReactorResourceFactoryTests { this.resourceFactory.destroy(); // Managed (destroy disposes).. - verify(this.connectionProvider).dispose(); - verify(this.loopResources).dispose(); + verify(this.connectionProvider).disposeLater(); + verify(this.loopResources).disposeLater(); verifyNoMoreInteractions(this.connectionProvider, this.loopResources); }