diff --git a/transport/src/main/java/io/netty/channel/socket/nio/AbstractNioByteChannel.java b/transport/src/main/java/io/netty/channel/socket/nio/AbstractNioByteChannel.java index 90ddf6b597..a7c35e5e7a 100755 --- a/transport/src/main/java/io/netty/channel/socket/nio/AbstractNioByteChannel.java +++ b/transport/src/main/java/io/netty/channel/socket/nio/AbstractNioByteChannel.java @@ -35,7 +35,7 @@ abstract class AbstractNioByteChannel extends AbstractNioChannel { return new NioByteUnsafe(); } - final class NioByteUnsafe extends AbstractNioUnsafe { + private final class NioByteUnsafe extends AbstractNioUnsafe { @Override public void read() { assert eventLoop().inEventLoop(); diff --git a/transport/src/main/java/io/netty/channel/socket/nio/AbstractNioMessageChannel.java b/transport/src/main/java/io/netty/channel/socket/nio/AbstractNioMessageChannel.java index 4275efc7e3..f98ce6c9fa 100755 --- a/transport/src/main/java/io/netty/channel/socket/nio/AbstractNioMessageChannel.java +++ b/transport/src/main/java/io/netty/channel/socket/nio/AbstractNioMessageChannel.java @@ -34,7 +34,7 @@ abstract class AbstractNioMessageChannel extends AbstractNioChannel { return new NioMessageUnsafe(); } - final class NioMessageUnsafe extends AbstractNioUnsafe { + private final class NioMessageUnsafe extends AbstractNioUnsafe { @Override public void read() { assert eventLoop().inEventLoop(); diff --git a/transport/src/main/java/io/netty/channel/socket/oio/AbstractOioByteChannel.java b/transport/src/main/java/io/netty/channel/socket/oio/AbstractOioByteChannel.java index f818d6e6a5..0de6430775 100755 --- a/transport/src/main/java/io/netty/channel/socket/oio/AbstractOioByteChannel.java +++ b/transport/src/main/java/io/netty/channel/socket/oio/AbstractOioByteChannel.java @@ -28,9 +28,11 @@ abstract class AbstractOioByteChannel extends AbstractOioChannel { } @Override - protected abstract AbstractOioByteUnsafe newUnsafe(); + protected OioByteUnsafe newUnsafe() { + return new OioByteUnsafe(); + } - abstract class AbstractOioByteUnsafe extends AbstractOioUnsafe { + private final class OioByteUnsafe extends AbstractOioUnsafe { @Override public void read() { assert eventLoop().inEventLoop(); diff --git a/transport/src/main/java/io/netty/channel/socket/oio/AbstractOioChannel.java b/transport/src/main/java/io/netty/channel/socket/oio/AbstractOioChannel.java index 647919f234..9bf58d8f1c 100644 --- a/transport/src/main/java/io/netty/channel/socket/oio/AbstractOioChannel.java +++ b/transport/src/main/java/io/netty/channel/socket/oio/AbstractOioChannel.java @@ -27,6 +27,8 @@ abstract class AbstractOioChannel extends AbstractChannel { static final int SO_TIMEOUT = 1000; + protected volatile boolean readSuspended; + protected AbstractOioChannel(Channel parent, Integer id) { super(parent, id); } @@ -51,7 +53,6 @@ abstract class AbstractOioChannel extends AbstractChannel { } abstract class AbstractOioUnsafe extends AbstractUnsafe implements OioUnsafe { - @Override public void connect( final SocketAddress remoteAddress, @@ -82,6 +83,16 @@ abstract class AbstractOioChannel extends AbstractChannel { }); } } + + @Override + public void suspendRead() { + readSuspended = true; + } + + @Override + public void resumeRead() { + readSuspended = false; + } } @Override diff --git a/transport/src/main/java/io/netty/channel/socket/oio/AbstractOioMessageChannel.java b/transport/src/main/java/io/netty/channel/socket/oio/AbstractOioMessageChannel.java index 8ef383d5c7..3272562ca8 100755 --- a/transport/src/main/java/io/netty/channel/socket/oio/AbstractOioMessageChannel.java +++ b/transport/src/main/java/io/netty/channel/socket/oio/AbstractOioMessageChannel.java @@ -28,9 +28,11 @@ abstract class AbstractOioMessageChannel extends AbstractOioChannel { } @Override - protected abstract AbstractOioMessageUnsafe newUnsafe(); + protected OioMessageUnsafe newUnsafe() { + return new OioMessageUnsafe(); + } - abstract class AbstractOioMessageUnsafe extends AbstractOioUnsafe { + private final class OioMessageUnsafe extends AbstractOioUnsafe { @Override public void read() { assert eventLoop().inEventLoop(); diff --git a/transport/src/main/java/io/netty/channel/socket/oio/OioDatagramChannel.java b/transport/src/main/java/io/netty/channel/socket/oio/OioDatagramChannel.java index 2586b0812f..6c45ad8fcb 100755 --- a/transport/src/main/java/io/netty/channel/socket/oio/OioDatagramChannel.java +++ b/transport/src/main/java/io/netty/channel/socket/oio/OioDatagramChannel.java @@ -52,8 +52,6 @@ public class OioDatagramChannel extends AbstractOioMessageChannel private final DatagramChannelConfig config; private final java.net.DatagramPacket tmpPacket = new java.net.DatagramPacket(EMPTY_DATA, 0); - private volatile boolean readSuspended; - private static MulticastSocket newSocket() { try { return new MulticastSocket(null); @@ -352,22 +350,4 @@ public class OioDatagramChannel extends AbstractOioMessageChannel future.setFailure(new UnsupportedOperationException()); return future; } - - @Override - protected AbstractOioMessageUnsafe newUnsafe() { - return new OioDatagramChannelUnsafe(); - } - - private final class OioDatagramChannelUnsafe extends AbstractOioMessageUnsafe { - - @Override - public void suspendRead() { - readSuspended = true; - } - - @Override - public void resumeRead() { - readSuspended = false; - } - } } diff --git a/transport/src/main/java/io/netty/channel/socket/oio/OioServerSocketChannel.java b/transport/src/main/java/io/netty/channel/socket/oio/OioServerSocketChannel.java index be358b789f..8f600e8a9a 100755 --- a/transport/src/main/java/io/netty/channel/socket/oio/OioServerSocketChannel.java +++ b/transport/src/main/java/io/netty/channel/socket/oio/OioServerSocketChannel.java @@ -54,8 +54,6 @@ public class OioServerSocketChannel extends AbstractOioMessageChannel final Lock shutdownLock = new ReentrantLock(); private final ServerSocketChannelConfig config; - private volatile boolean readSuspended; - public OioServerSocketChannel() { this(newServerSocket()); } @@ -192,22 +190,4 @@ public class OioServerSocketChannel extends AbstractOioMessageChannel protected void doWriteMessages(MessageBuf buf) throws Exception { throw new UnsupportedOperationException(); } - - @Override - protected AbstractOioMessageUnsafe newUnsafe() { - return new OioServerSocketUnsafe(); - } - - private final class OioServerSocketUnsafe extends AbstractOioMessageUnsafe { - - @Override - public void suspendRead() { - readSuspended = true; - } - - @Override - public void resumeRead() { - readSuspended = false; - } - } } diff --git a/transport/src/main/java/io/netty/channel/socket/oio/OioSocketChannel.java b/transport/src/main/java/io/netty/channel/socket/oio/OioSocketChannel.java index 85b80e050c..a1cef7af85 100755 --- a/transport/src/main/java/io/netty/channel/socket/oio/OioSocketChannel.java +++ b/transport/src/main/java/io/netty/channel/socket/oio/OioSocketChannel.java @@ -46,7 +46,6 @@ public class OioSocketChannel extends AbstractOioByteChannel private final SocketChannelConfig config; private InputStream is; private OutputStream os; - private volatile boolean readSuspended; public OioSocketChannel() { this(new Socket()); @@ -186,23 +185,4 @@ public class OioSocketChannel extends AbstractOioByteChannel } buf.readBytes(os, buf.readableBytes()); } - - - @Override - protected AbstractOioByteUnsafe newUnsafe() { - return new OioSocketChannelUnsafe(); - } - - private final class OioSocketChannelUnsafe extends AbstractOioByteUnsafe { - - @Override - public void suspendRead() { - readSuspended = true; - } - - @Override - public void resumeRead() { - readSuspended = false; - } - } }