Skip to content

Commit

Permalink
Warn about usage of Quarkus#blockingExit on the main thread
Browse files Browse the repository at this point in the history
Relates to: #28899

(cherry picked from commit 04652b7)
  • Loading branch information
geoand authored and gsmet committed Nov 1, 2022
1 parent 6637c77 commit b5b794c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/runtime/src/main/java/io/quarkus/runtime/Quarkus.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.Closeable;
import java.io.IOException;
import java.util.Locale;
import java.util.function.BiConsumer;

import org.jboss.logging.Logger;
Expand Down Expand Up @@ -179,6 +180,12 @@ public static void waitForExit() {
* Must not be called by the main thread, or a deadlock will result.
*/
public static void blockingExit() {
if (Thread.currentThread().getThreadGroup().getName().equals("main") &&
Thread.currentThread().getName().toLowerCase(Locale.ROOT).contains("main")) {
Logger.getLogger(Quarkus.class).error(
"'Quarkus#blockingExit' was called on the main thread. This will result in deadlocking the application!");
}

Application app = Application.currentApplication();
asyncExit();
if (app != null) {
Expand Down

0 comments on commit b5b794c

Please sign in to comment.