use of reactor.netty.resources.LoopResources in project spring-framework by spring-projects.
the class ReactorResourceFactoryTests method localResourcesViaSupplier.
@Test
void localResourcesViaSupplier() throws Exception {
this.resourceFactory.setUseGlobalResources(false);
this.resourceFactory.setConnectionProviderSupplier(() -> this.connectionProvider);
this.resourceFactory.setLoopResourcesSupplier(() -> this.loopResources);
this.resourceFactory.afterPropertiesSet();
ConnectionProvider connectionProvider = this.resourceFactory.getConnectionProvider();
LoopResources loopResources = this.resourceFactory.getLoopResources();
assertThat(connectionProvider).isSameAs(this.connectionProvider);
assertThat(loopResources).isSameAs(this.loopResources);
verifyNoMoreInteractions(this.connectionProvider, this.loopResources);
this.resourceFactory.destroy();
// Managed (destroy disposes)..
verify(this.connectionProvider).disposeLater();
verify(this.loopResources).disposeLater(eq(Duration.ofSeconds(LoopResources.DEFAULT_SHUTDOWN_QUIET_PERIOD)), eq(Duration.ofSeconds(LoopResources.DEFAULT_SHUTDOWN_TIMEOUT)));
verifyNoMoreInteractions(this.connectionProvider, this.loopResources);
}
use of reactor.netty.resources.LoopResources in project spring-framework by spring-projects.
the class ReactorResourceFactoryTests method localResources.
@Test
void localResources() throws Exception {
this.resourceFactory.setUseGlobalResources(false);
this.resourceFactory.afterPropertiesSet();
ConnectionProvider connectionProvider = this.resourceFactory.getConnectionProvider();
LoopResources loopResources = this.resourceFactory.getLoopResources();
assertThat(connectionProvider).isNotSameAs(HttpResources.get());
assertThat(loopResources).isNotSameAs(HttpResources.get());
// The below does not work since ConnectionPoolProvider simply checks if pool is empty.
// assertFalse(connectionProvider.isDisposed());
assertThat(loopResources.isDisposed()).isFalse();
this.resourceFactory.destroy();
assertThat(connectionProvider.isDisposed()).isTrue();
assertThat(loopResources.isDisposed()).isTrue();
}
use of reactor.netty.resources.LoopResources in project spring-framework by spring-projects.
the class ReactorResourceFactoryTests method externalResources.
@Test
void externalResources() throws Exception {
this.resourceFactory.setUseGlobalResources(false);
this.resourceFactory.setConnectionProvider(this.connectionProvider);
this.resourceFactory.setLoopResources(this.loopResources);
this.resourceFactory.afterPropertiesSet();
ConnectionProvider connectionProvider = this.resourceFactory.getConnectionProvider();
LoopResources loopResources = this.resourceFactory.getLoopResources();
assertThat(connectionProvider).isSameAs(this.connectionProvider);
assertThat(loopResources).isSameAs(this.loopResources);
verifyNoMoreInteractions(this.connectionProvider, this.loopResources);
this.resourceFactory.destroy();
// Not managed (destroy has no impact)..
verifyNoMoreInteractions(this.connectionProvider, this.loopResources);
}
use of reactor.netty.resources.LoopResources in project spring-boot by spring-projects.
the class NettyReactiveWebServerFactory method createHttpServer.
private HttpServer createHttpServer() {
HttpServer server = HttpServer.create();
if (this.resourceFactory != null) {
LoopResources resources = this.resourceFactory.getLoopResources();
Assert.notNull(resources, "No LoopResources: is ReactorResourceFactory not initialized yet?");
server = server.runOn(resources).bindAddress(this::getListenAddress);
} else {
server = server.bindAddress(this::getListenAddress);
}
if (getSsl() != null && getSsl().isEnabled()) {
server = customizeSslConfiguration(server);
}
if (getCompression() != null && getCompression().getEnabled()) {
CompressionCustomizer compressionCustomizer = new CompressionCustomizer(getCompression());
server = compressionCustomizer.apply(server);
}
server = server.protocol(listProtocols()).forwarded(this.useForwardHeaders);
return applyCustomizers(server);
}
Aggregations