[tomcat] branch 9.0.x updated: Fix bug 65001 Fix error handling for exceptions in [Read|Write]Listener

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[tomcat] branch 9.0.x updated: Fix bug 65001 Fix error handling for exceptions in [Read|Write]Listener

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

markt 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 d6d3259  Fix bug 65001 Fix error handling for exceptions in [Read|Write]Listener
d6d3259 is described below

commit d6d3259d74bd852d81bff6d60e72d6ca8c57923a
Author: Mark Thomas <[hidden email]>
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 740fa94..2288451 100644
--- a/java/org/apache/catalina/connector/CoyoteAdapter.java
+++ b/java/org/apache/catalina/connector/CoyoteAdapter.java
@@ -185,8 +185,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);
                     }
@@ -207,8 +212,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 2db2cf8..6b0c60c 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -167,6 +167,10 @@
         <code>unixDomainSocketPathPermissions</code> attributes.
         Based on a PR submitted by Graham Leggett. (remm)
       </add>
+      <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: [hidden email]
For additional commands, e-mail: [hidden email]