This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 87dfa39db4 Review "Fix silent loss of error reports in
ProxyErrorReportValve ..."
87dfa39db4 is described below
commit 87dfa39db48e46ab2ee6af33fe76b169a15eff7b
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Oct 29 15:25:35 2026 +0000
Review "Fix silent loss of error reports in ProxyErrorReportValve ..."
Reset the response and use the fall-back if the proxy fails before the
response is committed.
Abort the connection if the proxy fails after the response is committed
---
.../catalina/valves/ProxyErrorReportValve.java | 23 +++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/java/org/apache/catalina/valves/ProxyErrorReportValve.java
b/java/org/apache/catalina/valves/ProxyErrorReportValve.java
index 52da5e0e97..ca9196170a 100644
--- a/java/org/apache/catalina/valves/ProxyErrorReportValve.java
+++ b/java/org/apache/catalina/valves/ProxyErrorReportValve.java
@@ -310,11 +310,24 @@ public class ProxyErrorReportValve extends
ErrorReportValve {
if (log.isWarnEnabled()) {
log.warn(sm.getString("proxyErrorReportValve.error",
urlString), failure);
}
- // Discard any target metadata that was applied to this
response before the failure, so that a stale
- // Content-Length cannot truncate or suppress the fallback
report. Fall back to the default error
- // report rather than returning an empty response. The
reported flag is consumed by super.report().
- response.setContentLength(-1);
- super.report(request, response, throwable);
+ if (response.isCommitted()) {
+ /*
+ * Headers have already been sent. Need to abort the
connection so the client sees an incomplete
+ * response.
+ */
+ response.setErrorReported();
+ response.getCoyoteResponse().action(ActionCode.CLOSE_NOW,
failure);
+ } else {
+ /*
+ * Discard any target metadata that was applied to this
response before the failure, so that a stale
+ * Content-Length cannot truncate or suppress the fallback
report. Fall back to the default error
+ * report rather than returning an empty response. The
reported flag is consumed by super.report().
+ */
+ response.resetBuffer();
+ response.setContentType(null);
+ response.setContentLength(-1);
+ super.report(request, response, throwable);
+ }
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]