This is an automated email from the ASF dual-hosted git repository.
rmaucher pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new 8efd07a555 Add reason
8efd07a555 is described below
commit 8efd07a555281412cac60d040558ec2d5516294a
Author: remm <[email protected]>
AuthorDate: Thu Jul 16 10:56:34 2026 +0200
Add reason
Improve consistency with ErrorReportValve code.
---
java/org/apache/catalina/valves/JsonErrorReportValve.java | 13 +++++++++++--
webapps/docs/changelog.xml | 3 +++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/java/org/apache/catalina/valves/JsonErrorReportValve.java
b/java/org/apache/catalina/valves/JsonErrorReportValve.java
index cf6622d907..e023267dff 100644
--- a/java/org/apache/catalina/valves/JsonErrorReportValve.java
+++ b/java/org/apache/catalina/valves/JsonErrorReportValve.java
@@ -81,17 +81,26 @@ public class JsonErrorReportValve extends ErrorReportValve {
if (message == null) {
message = "";
}
- String description = smClient.getString("http." + statusCode +
".desc");
- if (description == null) {
+ String reason = null;
+ String description = null;
+ try {
+ reason = smClient.getString("http." + statusCode + ".reason");
+ description = smClient.getString("http." + statusCode +
".desc");
+ } catch (Throwable t) {
+ ExceptionUtils.handleThrowable(t);
+ }
+ if (reason == null || description == null) {
if (message.isEmpty()) {
return;
} else {
+ reason =
smClient.getString("errorReportValve.unknownReason");
description =
smClient.getString("errorReportValve.noDescription");
}
}
sb.append(",\n");
sb.append(" \"type\":
\"").append(JSONFilter.escape(type)).append("\",\n");
sb.append(" \"message\":
\"").append(JSONFilter.escape(message)).append("\",\n");
+ sb.append(" \"reason\":
\"").append(JSONFilter.escape(reason)).append("\",\n");
sb.append(" \"description\":
\"").append(JSONFilter.escape(description));
if (throwable != null) {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index f8a2117b2f..9c29210350 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -132,6 +132,9 @@
rethrow it as an <code>IllegalStateException</code> as mandated by the
Servlet specification. (remm)
</fix>
+ <fix>
+ Add missing reason to the <code>JsonErrorReportValve</code>. (remm)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]