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

Handle RejectedOperationException in Mutiny infrastructure on shutdown #16434

Merged
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
@@ -1,6 +1,8 @@
package io.quarkus.mutiny.runtime;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
import java.util.function.BooleanSupplier;
import java.util.function.Consumer;

Expand All @@ -15,7 +17,19 @@ public class MutinyInfrastructure {
public static final String VERTX_EVENT_LOOP_THREAD_PREFIX = "vert.x-eventloop-thread-";

public void configureMutinyInfrastructure(ExecutorService exec) {
Infrastructure.setDefaultExecutor(exec);
Infrastructure.setDefaultExecutor(new Executor() {
@Override
public void execute(Runnable command) {
try {
exec.execute(command);
} catch (RejectedExecutionException e) {
if (!exec.isShutdown() && !exec.isTerminated()) {
throw e;
}
// Ignore the failure - the application has been shutdown.
}
}
});
}

public void configureDroppedExceptionHandler() {
Expand Down