Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Singleton bean with @ServerRequestFilter is removed in @QuarkusTest #26635

Closed
franck102 opened this issue Jul 10, 2022 · 5 comments
Closed

@Singleton bean with @ServerRequestFilter is removed in @QuarkusTest #26635

franck102 opened this issue Jul 10, 2022 · 5 comments
Labels
area/rest kind/bug Something isn't working triage/invalid This doesn't seem right

Comments

@franck102
Copy link

franck102 commented Jul 10, 2022

Describe the bug

Starting from a barebone Greeting project:

mvn io.quarkus.platform:quarkus-maven-plugin:2.10.2.Final:create \
    -DprojectGroupId=org.acme \
    -DprojectArtifactId=getting-started \
    -Dextensions="resteasy-reactive"

I have added a single LoggingFilter bean:

@Singleton
public class LoggingFilter {
 
    @ServerRequestFilter(priority = 0)
    public void getFilter(UriInfo info, ...

The filter works fine if I start Quarkus in dev mode using the quarkus:dev maven goal:

2022-07-10 09:27:58,135 INFO  [com.eas.LoggingFilter] (executor-thread-0) [1] 200 GET /hello "Hello from RESTEasy Reactive"

... however the filter is not registered when running QuarkusTest or QuarkusIntegrationTest:

@QuarkusTest
public class GreetingResourceTest

The test passes but requests/responses are not logged

Expected behavior

I would expect the LoggingFilter to be registered, and to log requests & responses

Actual behavior

No response

How to Reproduce?

Create Greeting project, add LoggingFilter class, and run GreetingResourceTest

Output of uname -a or ver

No response

Output of java -version

openjdk version "18.0.1.1" 2022-04-22 OpenJDK Runtime Environment (build 18.0.1.1+2-6) OpenJDK 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.9.2.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
Maven home: /opt/homebrew/Cellar/maven/3.8.5/libexec
Java version: 18.0.1.1, vendor: Homebrew, runtime: /opt/homebrew/Cellar/openjdk/18.0.1.1/libexec/openjdk.jdk/Contents/Home
Default locale: en_FR, platform encoding: UTF-8
OS name: "mac os x", version: "12.4", arch: "aarch64", family: "mac"

Additional information

No response

@franck102 franck102 added the kind/bug Something isn't working label Jul 10, 2022
@franck102 franck102 changed the title @ServerRequestFilter and @ServerResponseFilter ignored in QuarkusTest @Singleton bean with @ServerRequestFilter is removed in @QuarkusTest Jul 10, 2022
@franck102
Copy link
Author

franck102 commented Jul 10, 2022

Adding @Unremoveable to the LoggingFilter bean fixes the issue... is that the correct approach?

After reading https://quarkus.io/blog/unused-beans/ I would assume the the filter should be recognized by the resteasy extension, and not removed?

Also, adding
quarkus.log.category."io.quarkus.arc.processor".level=DEBUG
to application.properties has no effect when running the QuarkusTest (it works for quarkus:dev)... is there a way to troubleshoot the CDI setup for unit tests?

@quarkus-bot
Copy link

quarkus-bot bot commented Jul 11, 2022

/cc @FroMage, @stuartwdouglas

@geoand
Copy link
Contributor

geoand commented Jul 11, 2022

Do you mind sharing a project that exhibits the problem with a failing test?

Thanks

@geoand geoand added the triage/needs-reproducer We are waiting for a reproducer. label Jul 11, 2022
@franck102
Copy link
Author

I shared the project here:
https://github.com/franck102/quarkus-greeting

Running com.easypass.GreetingResourceTest#testHelloEndpoint generates logs if the @unremovable annotation is present only.

@geoand
Copy link
Contributor

geoand commented Jul 13, 2022

I tried your sample and works flawlessly with or without @Unremovable

@geoand geoand closed this as not planned Won't fix, can't repro, duplicate, stale Jul 13, 2022
@geoand geoand added triage/invalid This doesn't seem right and removed triage/needs-reproducer We are waiting for a reproducer. labels Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rest kind/bug Something isn't working triage/invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants