You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/01/07 16:40:31 UTC

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

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

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


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

commit 829bfd74cd9f08e38ce8671042819f289651f342
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 5f1b04f..e470ed9 100644
--- a/java/org/apache/catalina/connector/CoyoteAdapter.java
+++ b/java/org/apache/catalina/connector/CoyoteAdapter.java
@@ -181,8 +181,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);
                     }
@@ -203,8 +208,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 57c000b..6a08be2 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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org