From dec72dc2bc255c15488dde2f1b7d83d43d92b68d Mon Sep 17 00:00:00 2001 From: Clement Escoffier Date: Sat, 4 Nov 2023 10:06:35 +0100 Subject: [PATCH] Produce a 503 response when there no more worker threads to handle blocking requests --- .../io/quarkus/vertx/http/runtime/QuarkusErrorHandler.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/QuarkusErrorHandler.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/QuarkusErrorHandler.java index 9ae149270aded..a08fa7c6fd26b 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/QuarkusErrorHandler.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/QuarkusErrorHandler.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.Optional; import java.util.UUID; +import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Consumer; @@ -93,6 +94,12 @@ public void accept(Throwable throwable) { event.response().end(); return; } + + if (event.failure() instanceof RejectedExecutionException) { + // No more worker threads - return a 503 + event.response().setStatusCode(HttpResponseStatus.SERVICE_UNAVAILABLE.code()).end(); + return; + } } catch (IllegalStateException e) { //ignore this if the response is already started if (!event.response().ended()) {