Description
Describe the bug
When Kafka processor receives record the request context gets automatically activated. The problem is the data of RequestScope objects are not cleared.
Expected behavior
Every record received via Kafka starts with no/new request context.
Actual behavior
Every record received via Kafka uses same request context. When increasing the counter variable at the request context object the counter increases with every record. Expected behaviour would be the counter increases from zero to one for each record.
How to Reproduce?
use kafka-quickstart project
- create class Counter with annotation @RequestScoped
- create in class Counter a variable counter = 0
- create in class Counter method increase() which inceases and prints the counter by 1
- create class Worker with annotation @ApplicationScoped
- inject into Worker class the Counter class
- create in class Worker method process() with @ActivateRequestContext
- this process() method triggers the increase() method of the Counter class
- inject into QuotesProcessor class the Worker class
- in class QuotesProcessor in method process(String quoteRequest) trigger the method process() of class Worker
When creating new quotes via the UI and processing them in class QuotesProcessor in method process(String quoteRequest) using following comand:
Arc.container().requestContext().isActive()
you can see the request context is active, but thats wrong, he should not be active. Thats why you can see the increase of the counter in class Counter when receiving multiple quotes.
Manually deactivating and activating the context in class QuotesProcessor in method process(String quoteRequest) works:
Arc.container().requestContext().deactivate();
Arc.container().requestContext().activate();
Anyway it should work also without adding these rows.
Output of uname -a
or ver
No response
Output of java -version
Java(TM) SE Runtime Environment 18.9 (build 11.0.5+10-LTS)
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.4.1.Final
Build tool (ie. output of mvnw --version
or gradlew --version
)
maven 3.6.3
Additional information
No response