Skip to content

Commit

Permalink
Improve the error message thrown when a blocking call is called on
Browse files Browse the repository at this point in the history
Vert.x event loop thread
  • Loading branch information
ppalaga committed Jan 24, 2025
1 parent 5e14c6a commit dd4e2f5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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."));
}

}
Expand Down Expand Up @@ -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."));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));

}

Expand Down

0 comments on commit dd4e2f5

Please sign in to comment.