As of reactor/reactor-netty#860, Reactor Netty allows to configure the quiet period when disposing of the Netty resources.

We should expose this as an option in ReactorResourceFactory, as the default quiet period of 2 seconds can be a problem in test suites or while developing an application (e.g. Spring Boot devtools).

Comment From: bclozel

Before we implement this, I'd like to run things by @violetagg to make sure we're on the right track.

Since reactor/reactor-netty#860, there are additional methods on LoopResources to specify the quiet period when shutting them down. In Spring Framework, we have a ReactorResourceFactory that allows developers to configure in a central place LoopResources and ConnectionProvider.

In Spring Boot, we're creating a ReactorResourceFactory bean that's injected in WebClient instances and the Reactor Netty server. Global resources are used by default. The ReactorResourceFactory class implements the DisposableBean interface, so that the application context cleans up resources when the context is shutting down.

I've got a couple of questions regarding this new configuration option:

  1. In your opinion, is configuring the quiet period + timeout options on ReactorResourceFactory the right way to go? Those options are not available on Reactor Netty DisposableServer, so I guess this is the right place?

  2. Is there a preferred order when shutting things down between the Reactor Netty DisposableServer and LoopResources? What happens if the resources are shut before the server or vice versa?

  3. If we shut the DisposableServer down first and then the LoopResources, will the server try to clean up those resources first? In that case, we might still get the 2s quiet period by default?

Comment From: sbrannen

Temporary workaround for WebClientDataBufferAllocatingTests, where appropriate values for the durations are debatable:

@AfterAll
void destroyReactorResourceFactory() {
    if (factory.isUseGlobalResources()) {
        HttpResources.disposeLoopsAndConnectionsLater(Duration.ofMillis(50), Duration.ofMillis(50)).block();
    } else {
        this.factory.destroy();
    }
}

Comment From: violetagg

  1. In your opinion, is configuring the quiet period + timeout options on ReactorResourceFactory the right way to go? Those options are not available on Reactor Netty DisposableServer, so I guess this is the right place?

You can run the server with - global resources -> so you do not want to shut them down when the server shuts down - when the user provides the LoopResources, the user knows whether he/she wants to shut them.

So DisposableServer does not shut down the resources

  1. Is there a preferred order when shutting things down between the Reactor Netty DisposableServer and LoopResources? What happens if the resources are shut before the server or vice versa?

First stop the LoopResources then the DisposableServer so that you wait for the running tasks while the server is still alive.

  1. If we shut the DisposableServer down first and then the LoopResources, will the server try to clean up those resources first? In that case, we might still get the 2s quiet period by default?

DisposableServer does nothing with LoopResources, the opposite - when you shut down the LoopResources they will close the opened connections. The only thing that DisposableServer does is when you use global resources. Then when DisposableServer shuts down the connection pool cache is cleaned for the connections that contain DisposableServer address as a remote address.