From 3683cbfed07dacf06462dc022537770687b8905a Mon Sep 17 00:00:00 2001 From: Julien Ponge Date: Thu, 5 Nov 2020 15:45:24 +0100 Subject: [PATCH 1/2] Vert.x event-loop threads start as "vert.x-eventloop-thread-" This typo causes a bug where blocking checks fail when run on a Vert.x event-loop. --- .../test/java/io/quarkus/mutiny/deployment/test/MutinyTest.java | 2 +- .../java/io/quarkus/mutiny/runtime/MutinyInfrastructure.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/mutiny/deployment/src/test/java/io/quarkus/mutiny/deployment/test/MutinyTest.java b/extensions/mutiny/deployment/src/test/java/io/quarkus/mutiny/deployment/test/MutinyTest.java index b61959a5fc134..2012c53515982 100644 --- a/extensions/mutiny/deployment/src/test/java/io/quarkus/mutiny/deployment/test/MutinyTest.java +++ b/extensions/mutiny/deployment/src/test/java/io/quarkus/mutiny/deployment/test/MutinyTest.java @@ -91,7 +91,7 @@ public void testForbiddenUniBlocking() throws InterruptedException { throwable.set(err); } latch.countDown(); - }, "vertx-eventloop-thread-0").start(); + }, "vert.x-eventloop-thread-0").start(); Assertions.assertTrue(latch.await(5, TimeUnit.SECONDS)); Assertions.assertNull(item.get()); diff --git a/extensions/mutiny/runtime/src/main/java/io/quarkus/mutiny/runtime/MutinyInfrastructure.java b/extensions/mutiny/runtime/src/main/java/io/quarkus/mutiny/runtime/MutinyInfrastructure.java index a84a18093d972..4c298f9a113c1 100644 --- a/extensions/mutiny/runtime/src/main/java/io/quarkus/mutiny/runtime/MutinyInfrastructure.java +++ b/extensions/mutiny/runtime/src/main/java/io/quarkus/mutiny/runtime/MutinyInfrastructure.java @@ -36,7 +36,7 @@ public boolean getAsBoolean() { * calling from a Vert.x event-loop context / thread. */ String threadName = Thread.currentThread().getName(); - return !threadName.contains("vertx-eventloop-thread-"); + return !threadName.startsWith("vert.x-eventloop-thread-"); } }); } From 5332dc7fc348f7aa16906f2df0b51d7f4e8b20b3 Mon Sep 17 00:00:00 2001 From: Julien Ponge Date: Fri, 6 Nov 2020 08:43:45 +0100 Subject: [PATCH 2/2] Extract the Vert.x loop thread prefix as a constant --- .../java/io/quarkus/mutiny/deployment/test/MutinyTest.java | 3 ++- .../java/io/quarkus/mutiny/runtime/MutinyInfrastructure.java | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/extensions/mutiny/deployment/src/test/java/io/quarkus/mutiny/deployment/test/MutinyTest.java b/extensions/mutiny/deployment/src/test/java/io/quarkus/mutiny/deployment/test/MutinyTest.java index 2012c53515982..c94a0339f8d79 100644 --- a/extensions/mutiny/deployment/src/test/java/io/quarkus/mutiny/deployment/test/MutinyTest.java +++ b/extensions/mutiny/deployment/src/test/java/io/quarkus/mutiny/deployment/test/MutinyTest.java @@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.mutiny.runtime.MutinyInfrastructure; import io.quarkus.test.QuarkusUnitTest; import io.smallrye.mutiny.Multi; import io.smallrye.mutiny.Uni; @@ -91,7 +92,7 @@ public void testForbiddenUniBlocking() throws InterruptedException { throwable.set(err); } latch.countDown(); - }, "vert.x-eventloop-thread-0").start(); + }, MutinyInfrastructure.VERTX_EVENT_LOOP_THREAD_PREFIX + "0").start(); Assertions.assertTrue(latch.await(5, TimeUnit.SECONDS)); Assertions.assertNull(item.get()); diff --git a/extensions/mutiny/runtime/src/main/java/io/quarkus/mutiny/runtime/MutinyInfrastructure.java b/extensions/mutiny/runtime/src/main/java/io/quarkus/mutiny/runtime/MutinyInfrastructure.java index 4c298f9a113c1..1304b385f6c8b 100644 --- a/extensions/mutiny/runtime/src/main/java/io/quarkus/mutiny/runtime/MutinyInfrastructure.java +++ b/extensions/mutiny/runtime/src/main/java/io/quarkus/mutiny/runtime/MutinyInfrastructure.java @@ -12,6 +12,8 @@ @Recorder public class MutinyInfrastructure { + public static final String VERTX_EVENT_LOOP_THREAD_PREFIX = "vert.x-eventloop-thread-"; + public void configureMutinyInfrastructure(ExecutorService exec) { Infrastructure.setDefaultExecutor(exec); } @@ -36,7 +38,7 @@ public boolean getAsBoolean() { * calling from a Vert.x event-loop context / thread. */ String threadName = Thread.currentThread().getName(); - return !threadName.startsWith("vert.x-eventloop-thread-"); + return !threadName.startsWith(VERTX_EVENT_LOOP_THREAD_PREFIX); } }); }