Skip to content
Permalink
Browse files
CXF-8684: Default WebApplicationExceptionMapper should be less specif…
…ic by default (#933)
  • Loading branch information
reta committed Apr 5, 2022
1 parent f9af3f3 commit 30520f1b4c66601d0f74297f03b70dbe1ee8988f
Showing 2 changed files with 5 additions and 4 deletions.
@@ -185,7 +185,7 @@ public <T extends Throwable> ExceptionMapper<T> createExceptionMapper(Class<?> e
Message m) {

boolean makeDefaultWaeLeastSpecific =
MessageUtils.getContextualBoolean(m, MAKE_DEFAULT_WAE_LEAST_SPECIFIC, false);
MessageUtils.getContextualBoolean(m, MAKE_DEFAULT_WAE_LEAST_SPECIFIC, true);

return (ExceptionMapper<T>)exceptionMappers.stream()
.filter(em -> handleMapper(em, exceptionType, m, ExceptionMapper.class, Throwable.class, true))
@@ -531,14 +531,16 @@ public void testExceptionMappersHierarchy1() throws Exception {

@Test
public void testExceptionMappersHierarchy2() throws Exception {
Message m = new MessageImpl();
m.put("default.wae.mapper.least.specific", false);
ServerProviderFactory pf = ServerProviderFactory.getInstance();

TestRuntimeExceptionMapper rm = new TestRuntimeExceptionMapper();
pf.registerUserProvider(rm);
ExceptionMapper<WebApplicationException> em =
pf.createExceptionMapper(WebApplicationException.class, new MessageImpl());
pf.createExceptionMapper(WebApplicationException.class, m);
assertTrue(em instanceof WebApplicationExceptionMapper);
assertSame(rm, pf.createExceptionMapper(RuntimeException.class, new MessageImpl()));
assertSame(rm, pf.createExceptionMapper(RuntimeException.class, m));

WebApplicationExceptionMapper wm = new WebApplicationExceptionMapper();
pf.registerUserProvider(wm);
@@ -549,7 +551,6 @@ public void testExceptionMappersHierarchy2() throws Exception {
@Test
public void testExceptionMappersHierarchy3() throws Exception {
Message m = new MessageImpl();
m.put("default.wae.mapper.least.specific", true);
ServerProviderFactory pf = ServerProviderFactory.getInstance();

TestRuntimeExceptionMapper rm = new TestRuntimeExceptionMapper();

0 comments on commit 30520f1

Please sign in to comment.