quarkus: Broken context propagation in HTTP request that involves hibernate-reactive-panache, resteasy-reactive and qute
Describe the bug
The CDI request context is not active when a template (that leverages a @RequestScoped
bean) is rendered in a Uni
chain:
@GET
public Uni<TemplateInstance> get(@QueryParam("id") Long id) {
// Fruit extends io.quarkus.hibernate.reactive.panache.PanacheEntity
return Fruit.findById(id).onItem().transform(f -> Templates.fruit((Fruit) f));
}
How to Reproduce?
- Checkout this quarkus-quickstarts branch
- Run the modified
hibernate-reactive-panache-quickstart
in the dev mode (can be reproduced in the prod mode as well) - HTTP GET
http://localhost:8080/test/template?id=1
You should see a ContextNotActiveException
in the console.
UPDATE: I’ve added two more simplified resource methods which produce a slightly different error:
javax.enterprise.inject.IllegalProductException: Normal scoped producer method may not return null: io.quarkus.vertx.http.runtime.CurrentVertxRequest.getCurrent()
It seems that the request context is active but the CurrentVertxRequest
bean instance is not propagated.
How to get this error:
- HTTP GET
http://localhost:8080/test/simple?id=1
- this one does not involve a qute template - HTTP GET
http://localhost:8080/test/no-hibernate?id=1
- this one does not involvehibernate-reactive-panache
It might be as well a PEBKAC on my side. I would be more than happy if someone explains to me what’s going on here 😉
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 27 (26 by maintainers)
Commits related to this issue
- Ensure that CDI request scope is active in TemplateResponseUniHandler This does not completely solve #27229, but it is a step in the right direction. — committed to geoand/quarkus by geoand 2 years ago
- Merge pull request #27497 from geoand/#27229 Ensure that CDI request scope is active in TemplateResponseUniHandler — committed to quarkusio/quarkus by mkouba 2 years ago
- Ensure that CDI request scope is active in TemplateResponseUniHandler This does not completely solve #27229, but it is a step in the right direction. — committed to fercomunello/quarkus by geoand 2 years ago
- Ensure that CDI request scope is active in TemplateResponseUniHandler This does not completely solve #27229, but it is a step in the right direction. (cherry picked from commit edfd6114cd0345d7bb208... — committed to gsmet/quarkus by geoand 2 years ago
I’m going to close this one because I was not able to reproduce any of the problems after https://github.com/quarkusio/quarkus/pull/27497 and https://github.com/quarkusio/quarkus/pull/27443 were merged!