From 21837baca3c764608173f4a5c69e85307cf92b18 Mon Sep 17 00:00:00 2001 From: Mark Thomas Date: Thu, 18 Apr 2024 19:45:41 +0100 Subject: [PATCH] Add API that allows the error status for the response to be reset This is required to fix an issue with async where a dispatch after an error is still flagged as an error which causes the dispatch to be skipped. --- java/org/apache/catalina/connector/Response.java | 5 +++++ java/org/apache/coyote/Response.java | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/java/org/apache/catalina/connector/Response.java b/java/org/apache/catalina/connector/Response.java index 0effa36218c1..a0d7c8d932ac 100644 --- a/java/org/apache/catalina/connector/Response.java +++ b/java/org/apache/catalina/connector/Response.java @@ -373,6 +373,11 @@ public boolean setErrorReported() { } + public void resetError() { + getCoyoteResponse().resetError(); + } + + /** * Perform whatever actions are required to flush and close the output stream or writer, in a single operation. * diff --git a/java/org/apache/coyote/Response.java b/java/org/apache/coyote/Response.java index 8bc89249b7f0..ae157bfd6b9e 100644 --- a/java/org/apache/coyote/Response.java +++ b/java/org/apache/coyote/Response.java @@ -333,6 +333,11 @@ public boolean setErrorReported() { } + public void resetError() { + errorState.set(0); + } + + // -------------------- Methods -------------------- public void reset() throws IllegalStateException { @@ -656,7 +661,7 @@ public void recycle() { committed = false; commitTimeNanos = -1; errorException = null; - errorState.set(0); + resetError(); headers.recycle(); trailerFieldsSupplier = null; // Servlet 3.1 non-blocking write listener