You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by li...@apache.org on 2022/09/02 08:43:32 UTC
[tomcat] branch 10.0.x updated: Pull up duplicate check codes
This is an automated email from the ASF dual-hosted git repository.
lihan pushed a commit to branch 10.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.0.x by this push:
new 9ad34a856e Pull up duplicate check codes
9ad34a856e is described below
commit 9ad34a856edd88f9a0616c1e44be0d165c8d0bc4
Author: lihan <li...@apache.org>
AuthorDate: Fri Sep 2 16:41:28 2022 +0800
Pull up duplicate check codes
---
.../apache/catalina/valves/ErrorReportValve.java | 35 +++++++++++-----------
.../catalina/valves/JsonErrorReportValve.java | 18 -----------
2 files changed, 17 insertions(+), 36 deletions(-)
diff --git a/java/org/apache/catalina/valves/ErrorReportValve.java b/java/org/apache/catalina/valves/ErrorReportValve.java
index 126de87eb7..e7fbc696e4 100644
--- a/java/org/apache/catalina/valves/ErrorReportValve.java
+++ b/java/org/apache/catalina/valves/ErrorReportValve.java
@@ -141,6 +141,23 @@ public class ErrorReportValve extends ValveBase {
response.setSuspended(false);
try {
+ int statusCode = response.getStatus();
+
+ // Do nothing on a 1xx, 2xx and 3xx status
+ // Do nothing if anything has been written already
+ // Do nothing if the response hasn't been explicitly marked as in error
+ // and that error has not been reported.
+ if (statusCode < 400 || response.getContentWritten() > 0 || !response.setErrorReported()) {
+ return;
+ }
+
+ // If an error has occurred that prevents further I/O, don't waste time
+ // producing an error report that will never be read
+ AtomicBoolean result = new AtomicBoolean(false);
+ response.getCoyoteResponse().action(ActionCode.IS_IO_ALLOWED, result);
+ if (!result.get()) {
+ return;
+ }
report(request, response, throwable);
} catch (Throwable tt) {
ExceptionUtils.handleThrowable(tt);
@@ -160,25 +177,7 @@ public class ErrorReportValve extends ValveBase {
* a root cause exception
*/
protected void report(Request request, Response response, Throwable throwable) {
-
int statusCode = response.getStatus();
-
- // Do nothing on a 1xx, 2xx and 3xx status
- // Do nothing if anything has been written already
- // Do nothing if the response hasn't been explicitly marked as in error
- // and that error has not been reported.
- if (statusCode < 400 || response.getContentWritten() > 0 || !response.setErrorReported()) {
- return;
- }
-
- // If an error has occurred that prevents further I/O, don't waste time
- // producing an error report that will never be read
- AtomicBoolean result = new AtomicBoolean(false);
- response.getCoyoteResponse().action(ActionCode.IS_IO_ALLOWED, result);
- if (!result.get()) {
- return;
- }
-
ErrorPage errorPage = null;
if (throwable != null) {
errorPage = errorPageSupport.find(throwable);
diff --git a/java/org/apache/catalina/valves/JsonErrorReportValve.java b/java/org/apache/catalina/valves/JsonErrorReportValve.java
index 8ba4acbc3f..9da5c33550 100644
--- a/java/org/apache/catalina/valves/JsonErrorReportValve.java
+++ b/java/org/apache/catalina/valves/JsonErrorReportValve.java
@@ -41,25 +41,7 @@ public class JsonErrorReportValve extends ErrorReportValve {
@Override
protected void report(Request request, Response response, Throwable throwable) {
-
int statusCode = response.getStatus();
-
- // Do nothing on a 1xx, 2xx and 3xx status
- // Do nothing if anything has been written already
- // Do nothing if the response hasn't been explicitly marked as in error
- // and that error has not been reported.
- if (statusCode < 400 || response.getContentWritten() > 0 || !response.setErrorReported()) {
- return;
- }
-
- // If an error has occurred that prevents further I/O, don't waste time
- // producing an error report that will never be read
- AtomicBoolean result = new AtomicBoolean(false);
- response.getCoyoteResponse().action(ActionCode.IS_IO_ALLOWED, result);
- if (!result.get()) {
- return;
- }
-
StringManager smClient = StringManager.getManager(Constants.Package, request.getLocales());
response.setLocale(smClient.getLocale());
String type = null;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org