You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Server exception mapper method of the Rest-Interface implementation class is not registered for resource defined in the interface.
Motivation:
We generate server endpoints for our Rest-Interfaces from openapi.yaml files. Generator generates interfaces, and we need to write only the implementation classes. We do have multiple versions (v1, v2, ...) of rest interface (multiple openapi.yaml files) in one application. We would like to have a custom server exception mapper for each version, which will create a valid response to the corresponding version.
Current, but not the best, workaround:
To activate the server exception mapper for the implementation class, we need to copy @Path annotation from the interface to our implementation class.
Expected behavior
Server exception mapper method in implementation class of Rest-Interface should be registered only for resource defined in interface.
Actual behavior
Server exception mapper method of the Rest-Interface implementation class is not registered for a resource defined in the interface, or it is registered as a global server exception mapper.
Method exception of the class PingRestControllerV2 will be ignored.
Method exception of the class PingRestControllerV1 will be registered as a global server exception mapper.
Output of uname -a or ver
Linux andrej 6.2.0-36-generic #37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct 9 15:34:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Output of java -version
openjdk version "17.0.5" 2022-10-18 LTS OpenJDK Runtime Environment Zulu17.38+21-CA (build 17.0.5+8-LTS) OpenJDK 64-Bit Server VM Zulu17.38+21-CA (build 17.0.5+8-LTS, mixed mode, sharing)
Quarkus version or git rev
main
Build tool (ie. output of mvnw --version or gradlew --version)
Describe the bug
Hi, I am not sure if this is a bug or a feature.
Server exception mapper method of the Rest-Interface implementation class is not registered for resource defined in the interface.
Motivation:
We generate server endpoints for our Rest-Interfaces from openapi.yaml files. Generator generates interfaces, and we need to write only the implementation classes. We do have multiple versions (v1, v2, ...) of rest interface (multiple openapi.yaml files) in one application. We would like to have a custom server exception mapper for each version, which will create a valid response to the corresponding version.
Example project: https://github.com/onecx/onecx-tenant-svc/blob/main/src/main/java/org/onecx/tenant/rs/internal/controllers/TenantControllerInternal.java
Current, but not the best, workaround:
To activate the server exception mapper for the implementation class, we need to copy
@Path
annotation from the interface to our implementation class.Expected behavior
Server exception mapper method in implementation class of Rest-Interface should be registered only for resource defined in interface.
Actual behavior
Server exception mapper method of the Rest-Interface implementation class is not registered for a resource defined in the interface, or it is registered as a global server exception mapper.
How to Reproduce?
I create a simple example project: https://github.com/andrejpetras/quarkus-ex-mapper
mvn clean compile quarkus:dev
curl http://localhost:8080/v1?error=1
outputServerExceptionMapperV1: Custom error V1
curl http://localhost:8080/v2?error=1
outputServerExceptionMapperV1: Custom error V2
excepted:ServerExceptionMapperV2: Custom error V2
In both cases, the same server exception mapper is used as a global server exception mapper.
Method
exception
of the class PingRestControllerV2 will be ignored.Method
exception
of the class PingRestControllerV1 will be registered as a global server exception mapper.Output of
uname -a
orver
Linux andrej 6.2.0-36-generic #37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct 9 15:34:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Output of
java -version
openjdk version "17.0.5" 2022-10-18 LTS OpenJDK Runtime Environment Zulu17.38+21-CA (build 17.0.5+8-LTS) OpenJDK 64-Bit Server VM Zulu17.38+21-CA (build 17.0.5+8-LTS, mixed mode, sharing)
Quarkus version or git rev
main
Build tool (ie. output of
mvnw --version
orgradlew --version
)Java version: 17.0.5, vendor: Azul Systems, Inc., runtime: /home/andrej/programs/java/zulu17.38.21-ca-jdk17.0.5-linux_x64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "6.2.0-36-generic", arch: "amd64", family: "unix"
Additional information
No response
The text was updated successfully, but these errors were encountered: