Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vert.x: report exception for blocking message consumer methods #37270

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ public void testFailure() throws InterruptedException {

@Test
public void testFailureNoReplyHandler() throws InterruptedException {
verifyFailureNoReply("foo", "Foo is dead", IllegalStateException.class);
verifyFailureNoReply("foo-blocking", "Red is dead", IllegalStateException.class);
}

void verifyFailureNoReply(String address, String expectedMessage, Class<? extends Exception> expectedException)
throws InterruptedException {
Handler<Throwable> oldHandler = vertx.exceptionHandler();
try {
BlockingQueue<Object> synchronizer = new LinkedBlockingQueue<>();
Expand All @@ -71,10 +77,10 @@ public void handle(Throwable event) {
}
}
});
eventBus.send("foo", "bar");
eventBus.send(address, "hello");
Object ret = synchronizer.poll(2, TimeUnit.SECONDS);
assertTrue(ret instanceof IllegalStateException);
assertEquals("Foo is dead", ((IllegalStateException) ret).getMessage());
assertTrue(expectedException.isAssignableFrom(ret.getClass()));
assertEquals(expectedMessage, ((Throwable) ret).getMessage());
} finally {
vertx.exceptionHandler(oldHandler);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import io.smallrye.common.vertx.VertxContext;
import io.vertx.core.AsyncResult;
import io.vertx.core.Context;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.eventbus.EventBus;
Expand Down Expand Up @@ -147,7 +148,7 @@ public void run() {
}
});
} else {
dup.executeBlocking(new Callable<Void>() {
Future<Void> future = dup.executeBlocking(new Callable<Void>() {
@Override
public Void call() {
try {
Expand All @@ -163,6 +164,7 @@ public Void call() {
return null;
}
}, invoker.isOrdered());
future.onFailure(context::reportException);
}
} else {
// Will run on the context used for the consumer registration.
Expand Down
Loading