This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new da7bf80 Avoid using named classes for closed channel
da7bf80 is described below
commit da7bf806f3525ab58aa91379894a38cee4e336e6
Author: remm <[email protected]>
AuthorDate: Wed Mar 11 14:44:13 2020 +0100
Avoid using named classes for closed channel
Only the constant is needed.
---
java/org/apache/tomcat/util/net/Nio2Channel.java | 8 ++------
java/org/apache/tomcat/util/net/NioChannel.java | 8 ++------
java/org/apache/tomcat/util/net/NioEndpoint.java | 5 ++---
3 files changed, 6 insertions(+), 15 deletions(-)
diff --git a/java/org/apache/tomcat/util/net/Nio2Channel.java
b/java/org/apache/tomcat/util/net/Nio2Channel.java
index 4980170..9c57f02 100644
--- a/java/org/apache/tomcat/util/net/Nio2Channel.java
+++ b/java/org/apache/tomcat/util/net/Nio2Channel.java
@@ -248,11 +248,7 @@ public class Nio2Channel implements
AsynchronousByteChannel {
}
};
- static final Nio2Channel CLOSED_NIO2_CHANNEL = new ClosedNio2Channel();
- public static class ClosedNio2Channel extends Nio2Channel {
- public ClosedNio2Channel() {
- super(SocketBufferHandler.EMPTY);
- }
+ static final Nio2Channel CLOSED_NIO2_CHANNEL = new
Nio2Channel(SocketBufferHandler.EMPTY) {
@Override
public void close() throws IOException {
}
@@ -304,5 +300,5 @@ public class Nio2Channel implements AsynchronousByteChannel
{
public String toString() {
return "Closed Nio2Channel";
}
- }
+ };
}
diff --git a/java/org/apache/tomcat/util/net/NioChannel.java
b/java/org/apache/tomcat/util/net/NioChannel.java
index 75bc3f8..c1d4576 100644
--- a/java/org/apache/tomcat/util/net/NioChannel.java
+++ b/java/org/apache/tomcat/util/net/NioChannel.java
@@ -248,11 +248,7 @@ public class NioChannel implements ByteChannel,
ScatteringByteChannel, Gathering
return appReadBufHandler;
}
- static final NioChannel CLOSED_NIO_CHANNEL = new ClosedNioChannel();
- public static class ClosedNioChannel extends NioChannel {
- public ClosedNioChannel() {
- super(SocketBufferHandler.EMPTY);
- }
+ static final NioChannel CLOSED_NIO_CHANNEL = new
NioChannel(SocketBufferHandler.EMPTY) {
@Override
public void close() throws IOException {
}
@@ -292,6 +288,6 @@ public class NioChannel implements ByteChannel,
ScatteringByteChannel, Gathering
public String toString() {
return "Closed NioChannel";
}
- }
+ };
}
diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java
b/java/org/apache/tomcat/util/net/NioEndpoint.java
index 1a9f9de..0ed4200 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -52,7 +52,6 @@ import org.apache.tomcat.util.IntrospectionUtils;
import org.apache.tomcat.util.collections.SynchronizedQueue;
import org.apache.tomcat.util.collections.SynchronizedStack;
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;
/**
@@ -1208,7 +1207,7 @@ public class NioEndpoint extends
AbstractJsseEndpoint<NioChannel,SocketChannel>
private int fillReadBuffer(boolean block, ByteBuffer to) throws
IOException {
int nRead;
NioChannel socket = getSocket();
- if (socket instanceof ClosedNioChannel) {
+ if (socket == NioChannel.CLOSED_NIO_CHANNEL) {
throw new ClosedChannelException();
}
if (block) {
@@ -1238,7 +1237,7 @@ public class NioEndpoint extends
AbstractJsseEndpoint<NioChannel,SocketChannel>
@Override
protected void doWrite(boolean block, ByteBuffer from) throws
IOException {
NioChannel socket = getSocket();
- if (socket instanceof ClosedNioChannel) {
+ if (socket == NioChannel.CLOSED_NIO_CHANNEL) {
throw new ClosedChannelException();
}
if (block) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]