quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.58k stars 2.63k forks source link

Dependency quarkus-micrometer-registry-prometheus removes @Path annotation from a class #38010

Open interphase404 opened 8 months ago

interphase404 commented 8 months ago

Describe the bug

If dependency quarkus-micrometer-registry-prometheus is present, @Path annotation disappears from resource classes in runtime. For example it completely removes the possibility of calling method path(Class resource) from jakarta.ws.rs.core.UriBuilder because the class is required to be annotated with @Path and runtime doesn't have this information

Expected behavior

@Path annotation should be present when calling getClass().getAnnotations()

Actual behavior

@Path annotation is not present when calling getClass().getAnnotations()

How to Reproduce?

It is very simple to reproduce this issue.

  1. Create application using: quarkus create app --extension='resteasy-jackson'
  2. Add dependency quarkus-micrometer-registry-prometheus
  3. Attach debugger to created hello() method
  4. Call endpoint http://localhost:8080/hello
  5. Execute code in the debugger getClass().getAnnotations()

Output of uname -a or ver

No response

Output of java -version

openjdk version "11.0.20" 2023-07-18 OpenJDK Runtime Environment Temurin-11.0.20+8 (build 11.0.20+8) OpenJDK 64-Bit Server VM Temurin-11.0.20+8 (build 11.0.20+8, mixed mode)

Quarkus version or git rev

3.2.9, 3.6.4

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

Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)

Additional information

No response

quarkus-bot[bot] commented 8 months ago

/cc @brunobat (micrometer), @ebullient (micrometer)

brunobat commented 8 months ago

Not sure if I understand the problem, @interphase404 can you please add a reproducer?

interphase404 commented 8 months ago

I'm really sorry for not being able to describe this issue more clearly. Here is a reproducer: https://github.com/interphase404/quarkus-reproducer-38010

If you run it using: mvn quarkus:dev and call endpoint http://localhost:8080/annotations only this will be printed to the console: 2024-01-03 20:45:48,468 INFO [org.acm.AnnotationResource] (executor-thread-1) @jakarta.enterprise.context.ApplicationScoped()

However if you remove the dependncy quarkus-micrometer-registry-prometheus, then the console will display this: 2024-01-03 20:47:27,170 INFO [org.acm.AnnotationResource] (executor-thread-1) @jakarta.ws.rs.Path(value="/annotations") 2024-01-03 20:47:27,173 INFO [org.acm.AnnotationResource] (executor-thread-1) @jakarta.enterprise.context.ApplicationScoped()

brunobat commented 8 months ago

Got it! Sounds like a bug indeed.

geoand commented 8 months ago

This only happens with RESTEasy Classic (RESTeasy Reactive is not affected). The high level reason it happens is because the JAX-RS Resource class is scoped as @ApplicationScoped - why this happens I do not know.