Using ContextLocals: Issue when running non-API related JUnit tests #34222
-
Hi, We are developing some API Gateway app/units that perform the following:
We are using io.smallrye.common.vertx.ContextLocals for context propagation purposes, mainly for propagating incoming REST request related attributes (i.e. header values) throughout execution flow of this request. Additionally:
The issue we face is taking place when running some specific JUnit QuarkusTests, whose execution flow doesn't include RESTEasy related invocation, but do invoke the rest client directly. We are attaching a sample quarkus project, that reproduce s the issue. The app features a sample Resource API, and two JUnit tests. One API related, and one invoking a rest client directly. The destination is a mocked endpoint. We have also included a logging point in the Client Filter indicating whether it's on duplicated context or not. Here are the steps: 1. Run the application and perform a curl to /hello/greet endpoint:
In the above, context propagation works fine, and all the flow runs on duplicatedContext. 2. Run the API related JUnit test named testRequestBasedFlow:
In the above, context propagation works fine, and all the flow runs on duplicatedContext.
In the above, the flow is starting from JUnit's main thread and flow runs on root context. Long story short: it seems that when a processing unit isn't triggered through a RESTEasy API, Vert.x is unable to run the execution on duplicatedContext. We are on Quarkus 2.15.3.Final, and Java 11. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Thanks for the thorough report! I think I have understood what you want and if so, #34245 is the solution :) |
Beta Was this translation helpful? Give feedback.
Thanks for the thorough report!
I think I have understood what you want and if so, #34245 is the solution :)