This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/8.5.x by this push:
     new 5961f65  Fix bug 65001 Fix error handling for exceptions in 
[Read|Write]Listener
5961f65 is described below

commit 5961f658b739e2d51fc67b5ae275341f4b91f9d0
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Jan 7 16:40:03 2021 +0000

    Fix bug 65001 Fix error handling for exceptions in [Read|Write]Listener
    
    https://bz.apache.org/bugzilla/show_bug.cgi?id=65001
---
 java/org/apache/catalina/connector/CoyoteAdapter.java | 14 ++++++++++++--
 webapps/docs/changelog.xml                            |  4 ++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/connector/CoyoteAdapter.java 
b/java/org/apache/catalina/connector/CoyoteAdapter.java
index 46a7c9f..141fde7 100644
--- a/java/org/apache/catalina/connector/CoyoteAdapter.java
+++ b/java/org/apache/catalina/connector/CoyoteAdapter.java
@@ -192,8 +192,13 @@ public class CoyoteAdapter implements Adapter {
                         }
                     } catch (Throwable t) {
                         ExceptionUtils.handleThrowable(t);
+                        // Need to trigger the call to 
AbstractProcessor.setErrorState()
+                        // before the listener is called so the listener can 
call complete
+                        // Therefore no need to set success=false as that 
would trigger a
+                        // second call to AbstractProcessor.setErrorState()
+                        // https://bz.apache.org/bugzilla/show_bug.cgi?id=65001
+                        res.action(ActionCode.CLOSE_NOW, t);
                         writeListener.onError(t);
-                        success = false;
                     } finally {
                         request.getContext().unbind(false, oldCL);
                     }
@@ -214,8 +219,13 @@ public class CoyoteAdapter implements Adapter {
                         }
                     } catch (Throwable t) {
                         ExceptionUtils.handleThrowable(t);
+                        // Need to trigger the call to 
AbstractProcessor.setErrorState()
+                        // before the listener is called so the listener can 
call complete
+                        // Therefore no need to set success=false as that 
would trigger a
+                        // second call to AbstractProcessor.setErrorState()
+                        // https://bz.apache.org/bugzilla/show_bug.cgi?id=65001
+                        res.action(ActionCode.CLOSE_NOW, t);
                         readListener.onError(t);
-                        success = false;
                     } finally {
                         request.getContext().unbind(false, oldCL);
                     }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index bba0246..e9e7988 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -167,6 +167,10 @@
         combination with the Servlet non-blocking IO API. It was possible that
         some requests could get dropped. (markt)
       </fix>
+      <fix>
+        <bug>65001</bug>: Fix error handling for exceptions throw from calls
+        to <code>ReadListener</code> and <code>WriteListener</code>. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to