This is an automated email from the ASF dual-hosted git repository.
rmaucher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new 91e588c640 Add reason
91e588c640 is described below
commit 91e588c6409991fee91c11feda65924943b504b3
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 63e62a2917..9f562523fc 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 0c0bb4ec3d..06e4d26b69 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -253,6 +253,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]