-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for #25818 and upgrade to Mutiny 1.6.0
This is part of a coordinated fix across Quarkus and Mutiny where scheduler wrapping would cause Vert.x context propagation not to be done. See smallrye/smallrye-mutiny#955 Fixes #25818
- Loading branch information
Showing
5 changed files
with
208 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...tiny/src/main/java/io/quarkus/it/resteasy/mutiny/regression/bug25818/BlockingService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.quarkus.it.resteasy.mutiny.regression.bug25818; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
import io.vertx.core.Context; | ||
import io.vertx.core.Vertx; | ||
|
||
@ApplicationScoped | ||
public class BlockingService { | ||
|
||
public String getBlocking() { | ||
try { | ||
Thread.sleep(250); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
Context context = Vertx.currentContext(); | ||
if (context == null) { | ||
return "~~ context is null ~~"; | ||
} else { | ||
return "hello-" + context.getLocal("hello-target"); | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...y/src/main/java/io/quarkus/it/resteasy/mutiny/regression/bug25818/ReproducerResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package io.quarkus.it.resteasy.mutiny.regression.bug25818; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.jboss.logging.Logger; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
import io.smallrye.mutiny.infrastructure.Infrastructure; | ||
import io.vertx.core.Vertx; | ||
|
||
@Path("/reproducer/25818") | ||
public class ReproducerResource { | ||
|
||
private final Logger logger = Logger.getLogger(ReproducerResource.class); | ||
|
||
@Inject | ||
BlockingService service; | ||
|
||
private void addToContext() { | ||
Vertx.currentContext().putLocal("hello-target", "you"); | ||
} | ||
|
||
@GET | ||
@Path("/worker-pool") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public Uni<String> workerPool() { | ||
logger.info("worker pool endpoint"); | ||
addToContext(); | ||
return Uni.createFrom() | ||
.item(service::getBlocking) | ||
.runSubscriptionOn(Infrastructure.getDefaultWorkerPool()); | ||
} | ||
|
||
@GET | ||
@Path("/default-executor") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public Uni<String> defaultExecutor() { | ||
logger.info("default executor endpoint"); | ||
addToContext(); | ||
return Uni.createFrom() | ||
.item(service::getBlocking) | ||
.runSubscriptionOn(Infrastructure.getDefaultExecutor()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...ion-tests/resteasy-mutiny/src/test/java/io/quarkus/it/resteasy/mutiny/RegressionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.quarkus.it.resteasy.mutiny; | ||
|
||
import static io.restassured.RestAssured.get; | ||
import static org.hamcrest.CoreMatchers.is; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
public class RegressionTest { | ||
|
||
@Nested | ||
@DisplayName("Regression tests for #25818 (see https://github.com/quarkusio/quarkus/issues/25818)") | ||
public class Bug25818 { | ||
|
||
@Test | ||
public void testDefaultExecutor() { | ||
get("/reproducer/25818/default-executor") | ||
.then() | ||
.body(is("hello-you")) | ||
.statusCode(200); | ||
} | ||
|
||
@Test | ||
public void testWorkerPool() { | ||
get("/reproducer/25818/worker-pool") | ||
.then() | ||
.body(is("hello-you")) | ||
.statusCode(200); | ||
} | ||
} | ||
} |