use of reactor.netty.internal.shaded.reactor.pool.PoolAcquireTimeoutException in project reactor-netty by reactor.
the class Http2Tests method doTestMaxActiveStreams.
void doTestMaxActiveStreams(HttpClient baseClient, int maxActiveStreams, int concurrency, int prefetch, int expectedOnNext, int expectedOnError) throws Exception {
Http2SslContextSpec serverCtx = Http2SslContextSpec.forServer(ssc.certificate(), ssc.privateKey());
Http2SslContextSpec clientCtx = Http2SslContextSpec.forClient().configure(builder -> builder.trustManager(InsecureTrustManagerFactory.INSTANCE));
disposableServer = createServer().protocol(HttpProtocol.H2).secure(spec -> spec.sslContext(serverCtx)).route(routes -> routes.post("/echo", (req, res) -> res.send(req.receive().aggregate().retain().delayElement(Duration.ofMillis(100))))).http2Settings(setting -> setting.maxConcurrentStreams(maxActiveStreams)).bindNow();
HttpClient client = baseClient.port(disposableServer.port()).protocol(HttpProtocol.H2).secure(spec -> spec.sslContext(clientCtx)).wiretap(true);
CountDownLatch latch = new CountDownLatch(1);
List<? extends Signal<? extends String>> list = Flux.range(0, 2).flatMapDelayError(i -> client.post().uri("/echo").send(ByteBufFlux.fromString(Mono.just("doTestMaxActiveStreams"))).responseContent().aggregate().asString().materialize(), concurrency, prefetch).collectList().doFinally(fin -> latch.countDown()).block(Duration.ofSeconds(30));
assertThat(latch.await(30, TimeUnit.SECONDS)).as("latch 30s").isTrue();
assertThat(list).isNotNull().hasSize(2);
int onNext = 0;
int onError = 0;
String msg = "Pool#acquire(Duration) has been pending for more than the configured timeout of 10ms";
for (int i = 0; i < 2; i++) {
Signal<? extends String> signal = list.get(i);
if (signal.isOnNext()) {
onNext++;
} else if (signal.getThrowable() instanceof PoolAcquireTimeoutException && signal.getThrowable().getMessage().contains(msg)) {
onError++;
}
}
assertThat(onNext).isEqualTo(expectedOnNext);
assertThat(onError).isEqualTo(expectedOnError);
}
Aggregations