diff --git a/java/org/apache/tomcat/util/net/Nio2Endpoint.java b/java/org/apache/tomcat/util/net/Nio2Endpoint.java index 171ffea8d81b..1364c455ac29 100644 --- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java +++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java @@ -1183,6 +1183,19 @@ protected void writeNonBlocking(byte[] buf, int off, int len) throws IOException */ @Override protected void writeNonBlocking(ByteBuffer from) throws IOException { + writeNonBlockingInternal(from); + } + + + /** + * {@inheritDoc} + *

+ * Overridden for NIO2 to enable a gathering write to be used to write + * all of the remaining data in a single additional write should a + * non-blocking write leave data in the buffer. + */ + @Override + protected void writeNonBlockingInternal(ByteBuffer from) throws IOException { // Note: Possible alternate behavior: // If there's non blocking abuse (like a test writing 1MB in a single // "non blocking" write), then block until the previous write is diff --git a/java/org/apache/tomcat/util/net/SocketWrapperBase.java b/java/org/apache/tomcat/util/net/SocketWrapperBase.java index dcb75443f802..21889c8d839d 100644 --- a/java/org/apache/tomcat/util/net/SocketWrapperBase.java +++ b/java/org/apache/tomcat/util/net/SocketWrapperBase.java @@ -621,12 +621,11 @@ protected void writeNonBlocking(ByteBuffer from) } - /* + /** * Separate method so it can be re-used by the socket write buffer to write * data to the network */ - void writeNonBlockingInternal(ByteBuffer from) throws IOException { - // TODO Explore refactoring this method back into writeNonBlocking + protected void writeNonBlockingInternal(ByteBuffer from) throws IOException { if (socketBufferHandler.isWriteBufferEmpty()) { writeNonBlockingDirect(from); } else {