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 2022/05/20 06:51:19 UTC

[tomcat] branch main updated: Refactor in preparation for fixing BZ 66077

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

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


The following commit(s) were added to refs/heads/main by this push:
     new b37c463f21 Refactor in preparation for fixing BZ 66077
b37c463f21 is described below

commit b37c463f218772e4cc8196d7d98577ae773ad2ce
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri May 20 07:51:07 2022 +0100

    Refactor in preparation for fixing BZ 66077
---
 java/org/apache/tomcat/util/net/NioEndpoint.java   | 23 ++++++++++++++++++++++
 .../apache/tomcat/util/net/SocketWrapperBase.java  | 21 +-------------------
 .../apache/coyote/http2/TestAbstractStream.java    |  5 +++++
 3 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java
index 5e547a2e32..e8348e90f0 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -1293,6 +1293,29 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel>
         }
 
 
+        @Override
+        protected boolean flushNonBlocking() throws IOException {
+            boolean dataLeft = !socketBufferHandler.isWriteBufferEmpty();
+
+            // Write to the socket, if there is anything to write
+            if (dataLeft) {
+                doWrite(false);
+                dataLeft = !socketBufferHandler.isWriteBufferEmpty();
+            }
+
+            if (!dataLeft && !nonBlockingWriteBuffer.isEmpty()) {
+                dataLeft = nonBlockingWriteBuffer.write(this, false);
+
+                if (!dataLeft && !socketBufferHandler.isWriteBufferEmpty()) {
+                    doWrite(false);
+                    dataLeft = !socketBufferHandler.isWriteBufferEmpty();
+                }
+            }
+
+            return dataLeft;
+        }
+
+
         @Override
         protected void doWrite(boolean block, ByteBuffer buffer) throws IOException {
             int n = 0;
diff --git a/java/org/apache/tomcat/util/net/SocketWrapperBase.java b/java/org/apache/tomcat/util/net/SocketWrapperBase.java
index bcfd2c4239..e32525ba0d 100644
--- a/java/org/apache/tomcat/util/net/SocketWrapperBase.java
+++ b/java/org/apache/tomcat/util/net/SocketWrapperBase.java
@@ -725,26 +725,7 @@ public abstract class SocketWrapperBase<E> {
     }
 
 
-    protected boolean flushNonBlocking() throws IOException {
-        boolean dataLeft = !socketBufferHandler.isWriteBufferEmpty();
-
-        // Write to the socket, if there is anything to write
-        if (dataLeft) {
-            doWrite(false);
-            dataLeft = !socketBufferHandler.isWriteBufferEmpty();
-        }
-
-        if (!dataLeft && !nonBlockingWriteBuffer.isEmpty()) {
-            dataLeft = nonBlockingWriteBuffer.write(this, false);
-
-            if (!dataLeft && !socketBufferHandler.isWriteBufferEmpty()) {
-                doWrite(false);
-                dataLeft = !socketBufferHandler.isWriteBufferEmpty();
-            }
-        }
-
-        return dataLeft;
-    }
+    protected abstract boolean flushNonBlocking() throws IOException;
 
 
     /**
diff --git a/test/org/apache/coyote/http2/TestAbstractStream.java b/test/org/apache/coyote/http2/TestAbstractStream.java
index 3ed0151dcf..79dca9ab23 100644
--- a/test/org/apache/coyote/http2/TestAbstractStream.java
+++ b/test/org/apache/coyote/http2/TestAbstractStream.java
@@ -359,6 +359,11 @@ public class TestAbstractStream {
         protected void doClose() {
         }
 
+        @Override
+        protected boolean flushNonBlocking() throws IOException {
+            return false;
+        }
+
         @Override
         protected void doWrite(boolean block, ByteBuffer from) throws IOException {
         }


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