Skip to content

Commit 4194208

Browse files
committed
Allow disabling Jackson exception mappers
1 parent bec7366 commit 4194208

File tree

26 files changed

+89
-69
lines changed

26 files changed

+89
-69
lines changed

CHANGELOG.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
# Version 3.15.0 (2021-09-30)
2-
3-
* [new] Java 21 support.
4-
* [new] Support for `jakarta.inject.*` while retaining `javax.inject.*` compatibility.
5-
* [nfo] Other `jakarta.*` packages are not supported yet.
6-
* [chg] Update javassist to 3.30.2-GA
7-
* [chg] Update guice to 6.0.0
8-
* [chg] Update guava to 33.1.0
9-
* [chg] Update typetools to 0.6.3
10-
* [chg] Update shiro to 1.13.0
11-
* [chg] Update Undertow to 2.2.31.Final
12-
* [chg] Update Jersey to 2.42
13-
* [chg] Update Hibernate Validator to 6.1.7.Final
1+
# Version 3.15.1 (2024-10-25)
2+
3+
* **[new]** Allow to disable Jackson exception mappers as they may disclose technical info to REST clients.
4+
Set `rest.exceptionMapping.jackson` and `rest.exceptionMapping.detailedUserMessage` to `false`. The exception will
5+
go through the default exception mapper, which logs them. To avoid this provide your own exception mapper.
6+
7+
# Version 3.15.0 (2024-04-17)
8+
9+
* **[new]** Java 21 support.
10+
* **[new]** Support for `jakarta.inject.*` while retaining `javax.inject.*` compatibility.
11+
* **[nfo]** Other `jakarta.*` packages are not supported yet.
12+
* **[chg]** Update javassist to 3.30.2-GA
13+
* **[chg]** Update guice to 6.0.0
14+
* **[chg]** Update guava to 33.1.0
15+
* **[chg]** Update typetools to 0.6.3
16+
* **[chg]** Update shiro to 1.13.0
17+
* **[chg]** Update Undertow to 2.2.31.Final
18+
* **[chg]** Update Jersey to 2.42
19+
* **[chg]** Update Hibernate Validator to 6.1.7.Final
1420

1521
# Version 3.14.0 (2021-09-30)
1622

cli/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<parent>
1515
<groupId>org.seedstack.seed</groupId>
1616
<artifactId>seed</artifactId>
17-
<version>3.15.0-SNAPSHOT</version>
17+
<version>3.15.1-SNAPSHOT</version>
1818
</parent>
1919

2020
<artifactId>seed-cli</artifactId>

core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<parent>
1515
<groupId>org.seedstack.seed</groupId>
1616
<artifactId>seed</artifactId>
17-
<version>3.15.0-SNAPSHOT</version>
17+
<version>3.15.1-SNAPSHOT</version>
1818
</parent>
1919

2020
<artifactId>seed-core</artifactId>

pom.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<groupId>org.seedstack.seed</groupId>
2121
<artifactId>seed</artifactId>
22-
<version>3.15.0-SNAPSHOT</version>
22+
<version>3.15.1-SNAPSHOT</version>
2323
<packaging>pom</packaging>
2424

2525
<properties>
@@ -38,7 +38,11 @@
3838
<aopalliance.version>1.0</aopalliance.version>
3939
<glassfish-javax.el.version>3.0.0</glassfish-javax.el.version>
4040
<arquillian.version>1.4.0.Final</arquillian.version>
41-
<tomcat.version>7.0.86</tomcat.version>
41+
<tomcat.version>9.0.90</tomcat.version>
42+
<javax.servlet.version>4.0.1</javax.servlet.version>
43+
<javax.websocket-api.version>1.1</javax.websocket-api.version>
44+
<rest-assured.version>5.4.0</rest-assured.version>
45+
<arquillian-tomcat-embedded-9.version>1.1.0.Final</arquillian-tomcat-embedded-9.version>
4246

4347
<compatibility.version>3.1.0</compatibility.version>
4448
</properties>

rest/core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<parent>
1515
<groupId>org.seedstack.seed</groupId>
1616
<artifactId>seed-rest</artifactId>
17-
<version>3.15.0-SNAPSHOT</version>
17+
<version>3.15.1-SNAPSHOT</version>
1818
</parent>
1919

2020
<artifactId>seed-rest-core</artifactId>

rest/core/src/main/java/org/seedstack/seed/rest/internal/RestPlugin.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ private void configureExceptionMappers() {
133133
LOGGER.debug("Default exception mapping is enabled");
134134
}
135135

136+
if (!restConfig.exceptionMapping().isJackson()) {
137+
providers.remove(JsonMappingExceptionMapper.class);
138+
providers.remove(JsonParseExceptionMapper.class);
139+
LOGGER.debug("Jackson exception mapping is disabled");
140+
} else {
141+
LOGGER.debug("Jackson exception mapping is enabled");
142+
}
143+
136144
if (!isDynamicValidationSupported() || !restConfig.exceptionMapping().isValidation()) {
137145
providers.remove(ValidationExceptionMapper.class);
138146
LOGGER.debug("Validation exception mapping is disabled");

rest/core/src/main/java/org/seedstack/seed/rest/internal/exceptionmapper/InternalErrorExceptionMapper.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
package org.seedstack.seed.rest.internal.exceptionmapper;
99

1010
import org.seedstack.seed.Application;
11-
import org.seedstack.seed.core.Seed;
1211
import org.seedstack.seed.rest.RestConfig;
1312
import org.seedstack.shed.exception.BaseException;
1413
import org.slf4j.Logger;
@@ -41,29 +40,28 @@ public InternalErrorExceptionMapper(Application application) {
4140
@Override
4241
public Response toResponse(Exception exception) {
4342
String uuid = UUID.randomUUID().toString();
44-
BaseException translatedException = Seed.translateException(exception);
45-
LOGGER.error(buildServerMessage(uuid, translatedException), translatedException);
43+
LOGGER.error(buildServerMessage(uuid, exception), exception);
4644
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
47-
.entity(buildUserMessage(uuid, translatedException))
45+
.entity(buildUserMessage(uuid, exception))
4846
.build();
4947
}
5048

51-
private String buildUserMessage(String uuid, BaseException baseException) {
49+
private String buildUserMessage(String uuid, Exception exception) {
5250
StringBuilder sb = new StringBuilder(16384);
5351
sb.append("Internal server error [").append(uuid).append("]");
5452
if (exceptionMappingConfig.isDetailedUserMessage()) {
55-
sb.append(": ").append(baseException.getDescription());
53+
sb.append(": ").append(exception instanceof BaseException ? ((BaseException) exception).getDescription() : exception.getMessage());
5654
}
5755
return sb.toString();
5856
}
5957

60-
private String buildServerMessage(String uuid, BaseException baseException) {
58+
private String buildServerMessage(String uuid, Exception exception) {
6159
StringBuilder sb = new StringBuilder(16384);
6260
sb.append("JAX-RS request error [").append(uuid).append("] on ").append(request.getRequestURI()).append("\n");
6361
if (exceptionMappingConfig.isDetailedLog()) {
64-
sb.append(baseException.toString());
62+
sb.append(exception.toString());
6563
} else {
66-
sb.append(baseException.getMessage());
64+
sb.append(exception.getMessage());
6765
}
6866
return sb.toString();
6967
}

rest/jersey2/pom.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<parent>
1515
<groupId>org.seedstack.seed</groupId>
1616
<artifactId>seed-rest</artifactId>
17-
<version>3.15.0-SNAPSHOT</version>
17+
<version>3.15.1-SNAPSHOT</version>
1818
</parent>
1919

2020
<artifactId>seed-rest-jersey2</artifactId>
@@ -154,8 +154,8 @@
154154
</dependency>
155155
<dependency>
156156
<groupId>org.jboss.arquillian.container</groupId>
157-
<artifactId>arquillian-tomcat-embedded-7</artifactId>
158-
<version>1.0.1.Final</version>
157+
<artifactId>arquillian-tomcat-embedded-9</artifactId>
158+
<version>${arquillian-tomcat-embedded-9.version}</version>
159159
<scope>test</scope>
160160
<exclusions>
161161
<exclusion>
@@ -170,12 +170,12 @@
170170
<version>${tomcat.version}</version>
171171
<scope>test</scope>
172172
</dependency>
173-
<dependency>
174-
<groupId>org.apache.tomcat.embed</groupId>
175-
<artifactId>tomcat-embed-logging-juli</artifactId>
176-
<version>${tomcat.version}</version>
177-
<scope>test</scope>
178-
</dependency>
173+
<!-- <dependency>-->
174+
<!-- <groupId>org.apache.tomcat.embed</groupId>-->
175+
<!-- <artifactId>tomcat-embed-logging-juli</artifactId>-->
176+
<!-- <version>${tomcat.version}</version>-->
177+
<!-- <scope>test</scope>-->
178+
<!-- </dependency>-->
179179
<dependency>
180180
<groupId>org.apache.tomcat.embed</groupId>
181181
<artifactId>tomcat-embed-jasper</artifactId>

rest/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<parent>
1414
<groupId>org.seedstack.seed</groupId>
1515
<artifactId>seed</artifactId>
16-
<version>3.15.0-SNAPSHOT</version>
16+
<version>3.15.1-SNAPSHOT</version>
1717
</parent>
1818

1919
<artifactId>seed-rest</artifactId>

rest/specs/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<parent>
1414
<groupId>org.seedstack.seed</groupId>
1515
<artifactId>seed-rest</artifactId>
16-
<version>3.15.0-SNAPSHOT</version>
16+
<version>3.15.1-SNAPSHOT</version>
1717
</parent>
1818

1919
<artifactId>seed-rest-specs</artifactId>

0 commit comments

Comments
 (0)