From dd4e2f5361a5a2940fd61917b438749e66ab04e0 Mon Sep 17 00:00:00 2001 From: Peter Palaga Date: Fri, 24 Jan 2025 11:28:16 +0100 Subject: [PATCH] Improve the error message thrown when a blocking call is called on Vert.x event loop thread --- .../deployment/test/Client3xx4xx5xxTest.java | 4 ++-- .../http/client/VertxHttpClientHTTPConduit.java | 17 ++++++++++------- .../it/vertx/async/AsyncVertxClientTest.java | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/extensions/core/deployment/src/test/java/io/quarkiverse/cxf/deployment/test/Client3xx4xx5xxTest.java b/extensions/core/deployment/src/test/java/io/quarkiverse/cxf/deployment/test/Client3xx4xx5xxTest.java index aca85946a..12c3f43ef 100644 --- a/extensions/core/deployment/src/test/java/io/quarkiverse/cxf/deployment/test/Client3xx4xx5xxTest.java +++ b/extensions/core/deployment/src/test/java/io/quarkiverse/cxf/deployment/test/Client3xx4xx5xxTest.java @@ -187,7 +187,7 @@ void wsdlUri200OnEventLoop() throws InterruptedException { .then() .statusCode(500) .body(CoreMatchers.containsString( - "java.lang.IllegalStateException You have attempted to perform a blocking operation on an IO thread.")); + "java.lang.IllegalStateException You have attempted to perform a blocking service method call on Vert.x event loop thread with CXF client wsdlUri200.")); } } @@ -223,7 +223,7 @@ void endpointUri404OnEventLoop() throws InterruptedException { .then() .statusCode(500) .body(CoreMatchers.containsString( - "java.lang.IllegalStateException You have attempted to perform a blocking operation on an IO thread.")); + "java.lang.IllegalStateException You have attempted to perform a blocking service method call on Vert.x event loop thread with CXF client endpointUri404.")); } diff --git a/extensions/core/runtime/src/main/java/io/quarkiverse/cxf/vertx/http/client/VertxHttpClientHTTPConduit.java b/extensions/core/runtime/src/main/java/io/quarkiverse/cxf/vertx/http/client/VertxHttpClientHTTPConduit.java index f1096e70c..3f7d4af0a 100644 --- a/extensions/core/runtime/src/main/java/io/quarkiverse/cxf/vertx/http/client/VertxHttpClientHTTPConduit.java +++ b/extensions/core/runtime/src/main/java/io/quarkiverse/cxf/vertx/http/client/VertxHttpClientHTTPConduit.java @@ -143,13 +143,16 @@ protected void setupConnection(Message message, Address address, HTTPClientPolic final boolean isAsync = useAsync.isAsync(message); message.put(USE_ASYNC, isAsync); - if (!isAsync && !BlockingOperationControl.isBlockingAllowed()) { - throw new IllegalStateException("You have attempted to perform a blocking operation on an IO thread." - + " This is not allowed, as blocking the IO thread will cause major performance issues with your application." - + " You need to offload the blocking CXF client call to a worker thread," - + " e.g. by using the @io.smallrye.common.annotation.Blocking annotation on a caller method" - + " where it is supported by the underlying Quarkus extension, such as quarkus-rest, quarkus-vertx," - + " quarkus-reactive-routes, quarkus-grpc, quarkus-messaging-* and possibly others."); + final boolean blockingAllowed = BlockingOperationControl.isBlockingAllowed(); + if (!isAsync && !blockingAllowed) { + throw new IllegalStateException( + "You have attempted to perform a blocking service method call on Vert.x event loop thread with CXF client " + + clientInfo.getConfigKey() + "." + + " This is not allowed, as blocking the IO thread will cause major performance issues with your application." + + " You need to offload the blocking CXF client call to a worker thread," + + " e.g. by using the @io.smallrye.common.annotation.Blocking annotation on a caller method" + + " where it is supported by the underlying Quarkus extension, such as quarkus-rest, quarkus-vertx," + + " quarkus-reactive-routes, quarkus-grpc, quarkus-messaging-* and possibly others."); } final HttpVersion version = getVersion(message, csPolicy); diff --git a/integration-tests/client-server/src/test/java/io/quarkiverse/cxf/it/vertx/async/AsyncVertxClientTest.java b/integration-tests/client-server/src/test/java/io/quarkiverse/cxf/it/vertx/async/AsyncVertxClientTest.java index c2d0f7344..bb341b8c0 100644 --- a/integration-tests/client-server/src/test/java/io/quarkiverse/cxf/it/vertx/async/AsyncVertxClientTest.java +++ b/integration-tests/client-server/src/test/java/io/quarkiverse/cxf/it/vertx/async/AsyncVertxClientTest.java @@ -33,7 +33,7 @@ void helloWithWsdl(String payloadSize) { .then() .statusCode(500) .body(CoreMatchers.containsString( - "You have attempted to perform a blocking operation on an IO thread.")); + "You have attempted to perform a blocking service method call on Vert.x event loop thread")); }