[
https://issues.apache.org/jira/browse/CXF-7473?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16348532#comment-16348532
]
Sergey Beryozkin commented on CXF-7473:
---------------------------------------
I'm revisiting this issue and have a workaround in place.
The biggest problem I've found with the existing code is how to decide when to
stop intrspecting.
Two examples:
{code:java}
public abstract class AbstractExceptionMapper<E extends Throwable> implements
ExceptionMapper<E> {
}
public class IllegalArgumentExceptionMapper extends
AbstractExceptionMapper<IllegalArgumentException> {
}
{code}
and
{code:java}
public class JacksonJsonProvider
extends ProviderBase<JacksonJsonProvider,
ObjectMapper,
JsonEndpointConfig, JsonMapperConfigurator>
{
}
{code}
In the former case we get IllegalArgumentException in the 1st step (when
checking the generic superclass), in the former - need to continue recursing.
I've tried checking the generic interfaces only, but in this case it works OK
for Jackson as it is typed by Object (MBR, MBW), while fails for the test case
as the generic interface reveals Throwable only.
I suspect a clean way exists to make sure it all becomes unambiguous, but it
would risky to start rewriting this code in a rush, so, as a workaround, I'm
adding a check which may help the runtime to decide that in case of a mismatch
no more recursing is needed... I'll keep the issue open though for now
> ExceptionMapper class hierarchies: incompatible ExceptionMapper selected
> ------------------------------------------------------------------------
>
> Key: CXF-7473
> URL: https://issues.apache.org/jira/browse/CXF-7473
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 3.1.11, 3.1.12
> Reporter: Jocelyn Lepage
> Priority: Major
>
> CXF seems to select an incompatible ExceptionMapper when using class
> hierarchies.
> More precisely, if I define an abstract exception class like following:
> {code:java}
> @Provider
> public abstract class AbstractExceptionMapper<E extends Throwable> implements
> ExceptionMapper<E> {
> ...
> {code}
> Then I define a concrete one for IllegalArgumentExceptions:
> {code:java}
> public class IllegalArgumentExceptionMapper extends
> AbstractExceptionMapper<IllegalArgumentException> {
> ...
> {code}
> IllegalArgumentExceptionMapper will then be selected even for
> RuntimeException subtypes unrelated to IllegalArgumentExceptions.
> See minimal project showing the problem
> [here|https://github.com/jlepage-appdirect/cxf-exception-mapper-bug]
> Similar (if not same) problem seems to have been reported via CXF-6635, but I
> do see this with 3.1.11 and 3.1.12.
> Thx!
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)