-
Notifications
You must be signed in to change notification settings - Fork 306
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
Bug Report: JAX-RS Remapping of wrapped exceptions using a custom mapper not working anymore/ FISH-9727 #6828
Comments
( Application level workaround we are introducing until the issue is fixed, just for the custom ValidationExceptionMapper: elcodedocle/payara-sscce@0fd3bc2 ) |
Hi @elcodedocle, I wasn't able to reproduce the error you're encountering. Could you please provide detailed steps on how to run the reproducer? This will help me ensure that I haven't missed any steps during my attempts to replicate the issue. Thank you, |
Hi Elif,
git clone --single-branch --branch payara-issue-6828 https://github.com/elcodedocle/payara-sscce
cd payara-sscce
mvn clean verify Requirements:
Files of interest:
You should be able to connect a JVM debugger to the exposed ${debug.port}, but you may have to delay execution of tests to connect before they run after the environment is deployed. To be clear: The observed deviation is that we expect ValidationExceptionMapper to be obtained here, as it happened in previous Payara releases, but that is not the case anymore; Instead, we get the default one. Best regards, |
Hi @elcodedocle, I was able to reproduce the issue and I have escalated this to the platform development team as Thank you, |
Brief Summary
Up until Payara 6.2024.1, whenever a custom JAX-RS
ExceptionMapper
(E.g.EJBExceptionMapper
) would handle an exception (E.g.EJBException
) wrapping another exception (E.g.ValidationException
) mapped by another custom mapper (E.g. a customValidationExceptionMapper
); the custom mapper (E.g.EJBExceptionMapper
) would be able to:EJBException
)ValidationException
)ValidationExceptionMapper
)This would produce the appropriate custom JAX-RS error response for that wrapped exception.
This is not the case anymore. Instead, the default mapper is selected over the custom one when requesting the mapper for the wrapped exception (E.g. via
Providers.getExceptionMapper(ValidationException.class)
). This results in a default error response for the wrapped exception, where the custom one was expected.We have a reproducer on https://github.com/elcodedocle/payara-sscce/tree/payara-issue-6828:
(It is not as minimal as it could be; Please ignore the storage layer)
Running
mvn clean verify
on this project will deploy and run tests on the Payara version specified in thepom.xml
file:ValidationException
.ValidationException
within an EJB transaction on a@Singleton
EJB, so it is wrapped within anEJBException
.EJBExceptionMapper
defined on the project.EJBExceptionMapper
will unwrap & handle theValidationException
wrapped on theEJBException
, using theValidationExceptionMapper
resolved from the injected@Context
throughproviders.getExceptionMapper((Class<Throwable>) unwrappedValidationException.getClass())
(WhereunwrappedValidationException.getClass()
resolves toValidationException.class
).ValidationException
on the JAX-RS resource itself, so it is not wrapped.ValidationExceptionMapper
that should return a BAD_REQUEST 400 status response when mapping theValidationException
, for both endpoints.The test for the endpoint that throws the wrapped exception will fail as described, for Payara 2024.1 and later.
The "control" test for the endpoint that throws the unwrapped exception will pass on any Payara version.
Expected Outcome
Exceptions unwrapped by custom mappers are handled by custom mappers that map them.
Current Outcome
Exceptions unwrapped by custom mappers are not captured by custom mappers that map them; a generic default error response from the default mapper is issued instead.
Reproducer
https://github.com/elcodedocle/payara-sscce/tree/payara-issue-6828
Operating System
Latest Debian 12 bookworm official Docker image
JDK Version
Latest OpenJDK 17 build from Debian 12 bookworm
Payara Distribution
Payara Server Full Profile
The text was updated successfully, but these errors were encountered: