This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit bad4d11a1cc15d7e0f22064d93f408473fa0d41f Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Feb 18 14:17:42 2022 +0000 s --- java/org/apache/tomcat/util/net/NioChannel.java | 5 ++++- java/org/apache/tomcat/util/net/NioEndpoint.java | 13 +++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/java/org/apache/tomcat/util/net/NioChannel.java b/java/org/apache/tomcat/util/net/NioChannel.java index ff8d329..d9bd848 100644 --- a/java/org/apache/tomcat/util/net/NioChannel.java +++ b/java/org/apache/tomcat/util/net/NioChannel.java @@ -273,7 +273,7 @@ public class NioChannel implements ByteChannel, ScatteringByteChannel, Gathering static final NioChannel CLOSED_NIO_CHANNEL = new ClosedNioChannel(); public static class ClosedNioChannel extends NioChannel { public ClosedNioChannel() { - super(null, null); + super(null, SocketBufferHandler.EMPTY); } @Override public void close() throws IOException { @@ -289,6 +289,9 @@ public class NioChannel implements ByteChannel, ScatteringByteChannel, Gathering public void free() { } @Override + public void setAppReadBufHandler(ApplicationBufferHandler handler) { + } + @Override public int read(ByteBuffer dst) throws IOException { return -1; } diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index 9813467..286f33e 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -28,6 +28,7 @@ import java.net.SocketTimeoutException; import java.nio.ByteBuffer; import java.nio.channels.CancelledKeyException; import java.nio.channels.Channel; +import java.nio.channels.ClosedChannelException; import java.nio.channels.CompletionHandler; import java.nio.channels.FileChannel; import java.nio.channels.NetworkChannel; @@ -53,6 +54,7 @@ import org.apache.tomcat.util.collections.SynchronizedQueue; import org.apache.tomcat.util.collections.SynchronizedStack; import org.apache.tomcat.util.compat.JrePlatform; import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; +import org.apache.tomcat.util.net.NioChannel.ClosedNioChannel; import org.apache.tomcat.util.net.jsse.JSSESupport; /** @@ -1335,7 +1337,10 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel> private int fillReadBuffer(boolean block, ByteBuffer to) throws IOException { int nRead; - NioChannel channel = getSocket(); + NioChannel socket = getSocket(); + if (socket instanceof ClosedNioChannel) { + throw new ClosedChannelException(); + } if (block) { Selector selector = null; try { @@ -1344,19 +1349,19 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel> // Ignore } try { - NioEndpoint.NioSocketWrapper att = (NioEndpoint.NioSocketWrapper) channel + NioEndpoint.NioSocketWrapper att = (NioEndpoint.NioSocketWrapper) socket .getAttachment(); if (att == null) { throw new IOException("Key must be cancelled."); } - nRead = pool.read(to, channel, selector, att.getReadTimeout()); + nRead = pool.read(to, socket, selector, att.getReadTimeout()); } finally { if (selector != null) { pool.put(selector); } } } else { - nRead = channel.read(to); + nRead = socket.read(to); if (nRead == -1) { throw new EOFException(); } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org