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
commit ea9a386aa3c3c1ce59afa4341099b960c7f74bf2 Author: Mark Thomas <ma...@apache.org> AuthorDate: Mon Mar 22 21:45:21 2021 +0000 Refactor setReadListener() in preparation for fix for BZ 64771 https://bz.apache.org/bugzilla/show_bug.cgi?id=64771 --- java/org/apache/catalina/connector/InputBuffer.java | 16 ---------------- java/org/apache/coyote/Request.java | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/java/org/apache/catalina/connector/InputBuffer.java b/java/org/apache/catalina/connector/InputBuffer.java index 0c8118b..a69effd 100644 --- a/java/org/apache/catalina/connector/InputBuffer.java +++ b/java/org/apache/catalina/connector/InputBuffer.java @@ -237,22 +237,6 @@ public class InputBuffer extends Reader public void setReadListener(ReadListener listener) { coyoteRequest.setReadListener(listener); - - // The container is responsible for the first call to - // listener.onDataAvailable(). If isReady() returns true, the container - // needs to call listener.onDataAvailable() from a new thread. If - // isReady() returns false, the socket will be registered for read and - // the container will call listener.onDataAvailable() once data arrives. - // Must call isFinished() first as a call to isReady() if the request - // has been finished will register the socket for read interest and that - // is not required. - if (!coyoteRequest.isFinished() && isReady()) { - coyoteRequest.action(ActionCode.DISPATCH_READ, null); - if (!ContainerThreadMarker.isContainerThread()) { - // Not on a container thread so need to execute the dispatch - coyoteRequest.action(ActionCode.DISPATCH_EXECUTE, null); - } - } } diff --git a/java/org/apache/coyote/Request.java b/java/org/apache/coyote/Request.java index e4fd4cd..7678111 100644 --- a/java/org/apache/coyote/Request.java +++ b/java/org/apache/coyote/Request.java @@ -191,6 +191,22 @@ public final class Request { } this.listener = listener; + + // The container is responsible for the first call to + // listener.onDataAvailable(). If isReady() returns true, the container + // needs to call listener.onDataAvailable() from a new thread. If + // isReady() returns false, the socket will be registered for read and + // the container will call listener.onDataAvailable() once data arrives. + // Must call isFinished() first as a call to isReady() if the request + // has been finished will register the socket for read interest and that + // is not required. + if (!isFinished() && isReady()) { + action(ActionCode.DISPATCH_READ, null); + if (!ContainerThreadMarker.isContainerThread()) { + // Not on a container thread so need to execute the dispatch + action(ActionCode.DISPATCH_EXECUTE, null); + } + } } public boolean isReady() { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org