This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/3.4.x-fixes by this push:
new f04e92fb65 CXF-8684: Default WebApplicationExceptionMapper should be
less specific by default (#933)
f04e92fb65 is described below
commit f04e92fb65737b53a6083a5e28d361db29ab1829
Author: Andriy Redko <[email protected]>
AuthorDate: Tue Apr 5 13:45:00 2022 -0400
CXF-8684: Default WebApplicationExceptionMapper should be less specific by
default (#933)
(cherry picked from commit 30520f1b4c66601d0f74297f03b70dbe1ee8988f)
(cherry picked from commit a11dfac5e5737f39b178f88d2f054892915223e5)
---
.../java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java | 2 +-
.../java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java | 7 ++++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
index e23479c996..ffa7402546 100644
---
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
+++
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
@@ -185,7 +185,7 @@ public final class ServerProviderFactory extends
ProviderFactory {
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))
diff --git
a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
index 34e7447db0..9183f6595e 100644
---
a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
+++
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
@@ -531,14 +531,16 @@ public class ProviderFactoryTest {
@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 class ProviderFactoryTest {
@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();