From 42742e233f4b7318d749339bfc6d03ed46e2f84e Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Wed, 13 Mar 2019 09:46:10 +0100 Subject: [PATCH] Deprecate ChannelInboundHandlerAdapter and ChannelOutboundHandlerAdapter (#8929) Motivation: As we now us java8 as minimum java version we can deprecate ChannelInboundHandlerAdapter / ChannelOutboundHandlerAdapter and just move the default implementations into the interfaces. This makes things a bit more flexible for the end-user and also simplifies the class-hierarchy. Modifications: - Mark ChannelInboundHandlerAdapter and ChannelOutboundHandlerAdapter as deprecated - Add default implementations to ChannelInboundHandler / ChannelOutboundHandler - Refactor our code to not use ChannelInboundHandlerAdapter / ChannelOutboundHandlerAdapter anymore Result: Cleanup class-hierarchy and make things a bit more flexible. --- .../http/HttpServerExpectContinueHandler.java | 6 +- .../http/websocketx/Utf8FrameValidator.java | 8 +- ...bSocketClientProtocolHandshakeHandler.java | 7 +- .../WebSocketServerProtocolHandler.java | 3 +- ...bSocketServerProtocolHandshakeHandler.java | 4 +- .../http/HttpClientUpgradeHandlerTest.java | 4 +- .../codec/http/HttpContentDecoderTest.java | 10 +- .../http/HttpContentDecompressorTest.java | 9 +- .../codec/http/HttpContentEncoderTest.java | 8 +- .../http/HttpServerUpgradeHandlerTest.java | 5 +- .../WebSocketServerProtocolHandlerTest.java | 8 +- .../http2/InboundHttpToHttp2Adapter.java | 6 +- ...leartextHttp2ServerUpgradeHandlerTest.java | 7 +- .../codec/http2/DataCompressionHttp2Test.java | 7 +- .../http2/Http2ClientUpgradeCodecTest.java | 8 +- .../http2/Http2ConnectionRoundtripTest.java | 9 +- .../codec/http2/Http2FrameCodecTest.java | 4 +- .../codec/http2/Http2FrameInboundWriter.java | 6 +- .../http2/Http2MultiplexCodecBuilderTest.java | 10 +- .../Http2MultiplexCodecClientUpgradeTest.java | 8 +- .../codec/http2/Http2MultiplexCodecTest.java | 39 +++--- .../http2/Http2ServerUpgradeCodecTest.java | 6 +- ...Http2StreamFrameToHttpObjectCodecTest.java | 8 +- .../HttpToHttp2ConnectionHandlerTest.java | 4 +- .../http2/InboundHttp2ToHttpAdapterTest.java | 8 +- .../handler/codec/ByteToMessageDecoder.java | 9 +- .../handler/codec/MessageToByteEncoder.java | 6 +- .../codec/MessageToMessageDecoder.java | 6 +- .../codec/MessageToMessageEncoder.java | 6 +- .../codec/ByteToMessageDecoderTest.java | 6 +- .../handler/codec/MessageAggregatorTest.java | 4 +- .../codec/MessageToMessageEncoderTest.java | 4 +- .../handler/codec/ReplayingDecoderTest.java | 6 +- .../netty/example/echo/EchoClientHandler.java | 4 +- .../netty/example/echo/EchoServerHandler.java | 4 +- .../client/Http2ClientInitializer.java | 6 +- .../frame/server/Http2ServerInitializer.java | 5 +- .../server/Http2ServerInitializer.java | 5 +- .../server/Http2ServerInitializer.java | 5 +- .../localecho/LocalEchoServerHandler.java | 4 +- .../objectecho/ObjectEchoClientHandler.java | 4 +- .../objectecho/ObjectEchoServerHandler.java | 4 +- .../netty/example/ocsp/OcspClientExample.java | 4 +- .../proxy/HexDumpProxyBackendHandler.java | 5 +- .../proxy/HexDumpProxyFrontendHandler.java | 4 +- .../example/sctp/SctpEchoClientHandler.java | 4 +- .../example/sctp/SctpEchoServerHandler.java | 4 +- .../socksproxy/DirectClientHandler.java | 4 +- .../example/socksproxy/RelayHandler.java | 4 +- .../handler/proxy/HttpProxyHandlerTest.java | 6 +- .../io/netty/handler/proxy/ProxyServer.java | 4 +- .../ipfilter/AbstractRemoteAddressFilter.java | 4 +- ...ApplicationProtocolNegotiationHandler.java | 4 +- .../handler/ssl/ocsp/OcspClientHandler.java | 4 +- .../handler/timeout/WriteTimeoutHandler.java | 4 +- .../handler/flow/FlowControlHandlerTest.java | 15 ++- .../flush/FlushConsolidationHandlerTest.java | 8 +- .../ssl/ParameterizedSslHandlerTest.java | 16 ++- .../io/netty/handler/ssl/RenegotiateTest.java | 7 +- .../io/netty/handler/ssl/SSLEngineTest.java | 24 ++-- .../handler/ssl/SniClientJava8TestUtil.java | 4 +- .../io/netty/handler/ssl/SniHandlerTest.java | 6 +- .../io/netty/handler/ssl/SslErrorTest.java | 6 +- .../io/netty/handler/ssl/SslHandlerTest.java | 30 ++--- .../io/netty/handler/ssl/ocsp/OcspTest.java | 14 +-- .../stream/ChunkedWriteHandlerTest.java | 10 +- .../handler/timeout/IdleStateHandlerTest.java | 8 +- .../http2/Http2FrameWriterDataBenchmark.java | 4 +- .../DefaultChannelPipelineBenchmark.java | 18 +-- .../netty/resolver/dns/DnsNameResolver.java | 6 +- .../autobahn/AutobahnServerHandler.java | 4 +- .../http2/Http2ServerInitializer.java | 5 +- .../CompositeBufferGatheringWriteTest.java | 10 +- .../socket/DatagramConnectNotExistsTest.java | 4 +- .../socket/ServerSocketSuspendTest.java | 4 +- .../transport/socket/SocketAutoReadTest.java | 4 +- .../SocketChannelNotYetConnectedTest.java | 4 +- .../socket/SocketCloseForciblyTest.java | 8 +- .../SocketConditionalWritabilityTest.java | 4 +- .../transport/socket/SocketConnectTest.java | 10 +- .../socket/SocketConnectionAttemptTest.java | 6 +- .../SocketDataReadInitialStateTest.java | 4 +- .../transport/socket/SocketEchoTest.java | 4 +- .../socket/SocketExceptionHandlingTest.java | 6 +- .../socket/SocketFileRegionTest.java | 3 +- .../socket/SocketHalfClosedTest.java | 15 ++- .../socket/SocketMultipleConnectTest.java | 6 +- .../socket/SocketObjectEchoTest.java | 4 +- .../socket/SocketReadPendingTest.java | 4 +- .../transport/socket/SocketRstTest.java | 6 +- .../SocketShutdownOutputBySelfTest.java | 4 +- .../socket/WriteBeforeRegisteredTest.java | 4 +- .../epoll/EpollDomainSocketFdTest.java | 7 +- .../channel/epoll/EpollReuseAddrTest.java | 6 +- .../EpollServerSocketChannelConfigTest.java | 4 +- .../epoll/EpollSocketChannelConfigTest.java | 4 +- .../channel/epoll/EpollSocketChannelTest.java | 8 +- .../channel/epoll/EpollSocketTcpMd5Test.java | 10 +- .../netty/channel/epoll/EpollSpliceTest.java | 10 +- .../kqueue/KQueueChannelConfigTest.java | 4 +- .../kqueue/KQueueDomainSocketFdTest.java | 7 +- .../KQueueServerSocketChannelConfigTest.java | 4 +- .../kqueue/KQueueSocketChannelConfigTest.java | 4 +- .../tests/DetectPeerCloseWithoutReadTest.java | 6 +- .../channel/sctp/SctpLimitStreamsTest.java | 1 - .../io/netty/bootstrap/ServerBootstrap.java | 4 +- .../netty/channel/ChannelDuplexHandler.java | 116 +---------------- .../java/io/netty/channel/ChannelHandler.java | 10 +- .../netty/channel/ChannelHandlerContext.java | 2 +- .../netty/channel/ChannelInboundHandler.java | 45 +++++-- .../channel/ChannelInboundHandlerAdapter.java | 112 +---------------- .../io/netty/channel/ChannelInitializer.java | 2 +- .../netty/channel/ChannelOutboundHandler.java | 47 +++++-- .../ChannelOutboundHandlerAdapter.java | 117 +----------------- .../io/netty/channel/ChannelPipeline.java | 4 +- .../channel/SimpleChannelInboundHandler.java | 4 +- .../SimpleUserEventChannelHandler.java | 4 +- .../io/netty/channel/group/ChannelGroup.java | 6 +- .../io/netty/bootstrap/BootstrapTest.java | 9 +- .../netty/bootstrap/ServerBootstrapTest.java | 14 +-- .../netty/channel/AbstractEventLoopTest.java | 2 +- .../netty/channel/ChannelInitializerTest.java | 12 +- .../channel/ChannelOutboundBufferTest.java | 8 +- .../CombinedChannelDuplexHandlerTest.java | 27 ++-- .../channel/DefaultChannelPipelineTest.java | 29 +++-- .../netty/channel/PendingWriteQueueTest.java | 10 +- .../netty/channel/ReentrantChannelTest.java | 16 +-- .../SimpleUserEventChannelHandlerTest.java | 2 +- .../channel/embedded/EmbeddedChannelTest.java | 28 ++--- .../group/DefaultChannelGroupTest.java | 4 +- .../netty/channel/local/LocalChannelTest.java | 54 ++++---- .../local/LocalTransportThreadModelTest2.java | 4 +- .../socket/nio/NioDatagramChannelTest.java | 4 +- .../socket/nio/NioSocketChannelTest.java | 10 +- 134 files changed, 563 insertions(+), 862 deletions(-) diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerExpectContinueHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerExpectContinueHandler.java index 4757ca29ac..db4f5a185f 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerExpectContinueHandler.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerExpectContinueHandler.java @@ -18,7 +18,7 @@ package io.netty.handler.codec.http; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.util.ReferenceCountUtil; import static io.netty.handler.codec.http.HttpHeaderNames.CONTENT_LENGTH; @@ -44,7 +44,7 @@ import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; * * */ -public class HttpServerExpectContinueHandler extends ChannelInboundHandlerAdapter { +public class HttpServerExpectContinueHandler implements ChannelInboundHandler { private static final FullHttpResponse EXPECTATION_FAILED = new DefaultFullHttpResponse( HTTP_1_1, HttpResponseStatus.EXPECTATION_FAILED, Unpooled.EMPTY_BUFFER); @@ -92,6 +92,6 @@ public class HttpServerExpectContinueHandler extends ChannelInboundHandlerAdapte req.headers().remove(HttpHeaderNames.EXPECT); } } - super.channelRead(ctx, msg); + ctx.fireChannelRead(msg); } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/Utf8FrameValidator.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/Utf8FrameValidator.java index 5ce5ec369c..7e37ae6a0e 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/Utf8FrameValidator.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/Utf8FrameValidator.java @@ -19,13 +19,13 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.handler.codec.CorruptedFrameException; /** * */ -public class Utf8FrameValidator extends ChannelInboundHandlerAdapter { +public class Utf8FrameValidator implements ChannelInboundHandler { private int fragmentedFramesCount; private Utf8Validator utf8Validator; @@ -74,7 +74,7 @@ public class Utf8FrameValidator extends ChannelInboundHandlerAdapter { } } - super.channelRead(ctx, msg); + ctx.fireChannelRead(msg); } private void checkUTF8String(ByteBuf buffer) { @@ -89,6 +89,6 @@ public class Utf8FrameValidator extends ChannelInboundHandlerAdapter { if (cause instanceof CorruptedFrameException && ctx.channel().isOpen()) { ctx.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE); } - super.exceptionCaught(ctx, cause); + ctx.fireExceptionCaught(cause); } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientProtocolHandshakeHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientProtocolHandshakeHandler.java index a7d06974c2..7077c017bd 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientProtocolHandshakeHandler.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientProtocolHandshakeHandler.java @@ -15,13 +15,12 @@ */ package io.netty.handler.codec.http.websocketx; -import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.handler.codec.http.FullHttpResponse; -class WebSocketClientProtocolHandshakeHandler extends ChannelInboundHandlerAdapter { +class WebSocketClientProtocolHandshakeHandler implements ChannelInboundHandler { private final WebSocketClientHandshaker handshaker; WebSocketClientProtocolHandshakeHandler(WebSocketClientHandshaker handshaker) { @@ -30,7 +29,7 @@ class WebSocketClientProtocolHandshakeHandler extends ChannelInboundHandlerAdapt @Override public void channelActive(final ChannelHandlerContext ctx) throws Exception { - super.channelActive(ctx); + ctx.fireChannelActive(); handshaker.handshake(ctx.channel()).addListener((ChannelFutureListener) future -> { if (!future.isSuccess()) { ctx.fireExceptionCaught(future.cause()); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java index 3a19b14542..2519989982 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java @@ -21,7 +21,6 @@ import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandler; -import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelPipeline; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.FullHttpRequest; @@ -199,7 +198,7 @@ public class WebSocketServerProtocolHandler extends WebSocketProtocolHandler { } static ChannelHandler forbiddenHttpRequestResponder() { - return new ChannelInboundHandlerAdapter() { + return new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof FullHttpRequest) { diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java index b5687749a2..db1161a240 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java @@ -18,7 +18,7 @@ package io.netty.handler.codec.http.websocketx; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelPipeline; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.FullHttpRequest; @@ -35,7 +35,7 @@ import static io.netty.handler.codec.http.HttpVersion.*; /** * Handles the HTTP handshake (the HTTP Upgrade request) for {@link WebSocketServerProtocolHandler}. */ -class WebSocketServerProtocolHandshakeHandler extends ChannelInboundHandlerAdapter { +class WebSocketServerProtocolHandshakeHandler implements ChannelInboundHandler { private final String websocketPath; private final String subprotocols; diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpClientUpgradeHandlerTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpClientUpgradeHandlerTest.java index a90ee575dd..f52d90adb1 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpClientUpgradeHandlerTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpClientUpgradeHandlerTest.java @@ -16,7 +16,7 @@ package io.netty.handler.codec.http; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.embedded.EmbeddedChannel; import java.util.Collection; @@ -58,7 +58,7 @@ public class HttpClientUpgradeHandlerTest { } } - private static final class UserEventCatcher extends ChannelInboundHandlerAdapter { + private static final class UserEventCatcher implements ChannelInboundHandler { private Object evt; public Object getUserEvent() { diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecoderTest.java index eb66a6fb7b..8af89e935d 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecoderTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecoderTest.java @@ -19,7 +19,7 @@ package io.netty.handler.codec.http; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.handler.codec.CodecException; import io.netty.handler.codec.DecoderException; @@ -274,7 +274,7 @@ public class HttpContentDecoderTest { final int maxBytes = 10; HttpObjectAggregator aggregator = new HttpObjectAggregator(maxBytes); final AtomicReference secondRequestRef = new AtomicReference<>(); - EmbeddedChannel channel = new EmbeddedChannel(decoder, aggregator, new ChannelInboundHandlerAdapter() { + EmbeddedChannel channel = new EmbeddedChannel(decoder, aggregator, new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof FullHttpRequest) { @@ -531,7 +531,7 @@ public class HttpContentDecoderTest { HttpContentDecoder decoder = new HttpContentDecoder() { @Override protected EmbeddedChannel newContentDecoder(String contentEncoding) throws Exception { - return new EmbeddedChannel(new ChannelInboundHandlerAdapter() { + return new EmbeddedChannel(new ChannelInboundHandler() { @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { ctx.fireExceptionCaught(new DecoderException()); @@ -542,11 +542,11 @@ public class HttpContentDecoderTest { }; final AtomicBoolean channelInactiveCalled = new AtomicBoolean(); - EmbeddedChannel channel = new EmbeddedChannel(decoder, new ChannelInboundHandlerAdapter() { + EmbeddedChannel channel = new EmbeddedChannel(decoder, new ChannelInboundHandler() { @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { assertTrue(channelInactiveCalled.compareAndSet(false, true)); - super.channelInactive(ctx); + ctx.fireChannelInactive(); } }); assertTrue(channel.writeInbound(new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/"))); diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecompressorTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecompressorTest.java index 4a659fad5e..7c1406d8e6 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecompressorTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecompressorTest.java @@ -17,8 +17,9 @@ package io.netty.handler.codec.http; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; -import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; + +import io.netty.channel.ChannelOutboundHandler; import io.netty.channel.embedded.EmbeddedChannel; import org.junit.Assert; import org.junit.Test; @@ -31,13 +32,13 @@ public class HttpContentDecompressorTest { @Test public void testInvokeReadWhenNotProduceMessage() { final AtomicInteger readCalled = new AtomicInteger(); - EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandlerAdapter() { + EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandler() { @Override public void read(ChannelHandlerContext ctx) { readCalled.incrementAndGet(); ctx.read(); } - }, new HttpContentDecompressor(), new ChannelInboundHandlerAdapter() { + }, new HttpContentDecompressor(), new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) { ctx.fireChannelRead(msg); diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpContentEncoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpContentEncoderTest.java index 6301ee8c0b..9fe6ee87c1 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpContentEncoderTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpContentEncoderTest.java @@ -19,7 +19,7 @@ package io.netty.handler.codec.http; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.handler.codec.CodecException; import io.netty.handler.codec.DecoderResult; @@ -397,7 +397,7 @@ public class HttpContentEncoderTest { @Override protected Result beginEncode(HttpResponse headers, String acceptEncoding) throws Exception { return new Result("myencoding", new EmbeddedChannel( - new ChannelInboundHandlerAdapter() { + new ChannelInboundHandler() { @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { ctx.fireExceptionCaught(new EncoderException()); @@ -408,11 +408,11 @@ public class HttpContentEncoderTest { }; final AtomicBoolean channelInactiveCalled = new AtomicBoolean(); - EmbeddedChannel channel = new EmbeddedChannel(encoder, new ChannelInboundHandlerAdapter() { + EmbeddedChannel channel = new EmbeddedChannel(encoder, new ChannelInboundHandler() { @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { assertTrue(channelInactiveCalled.compareAndSet(false, true)); - super.channelInactive(ctx); + ctx.fireChannelInactive(); } }); assertTrue(channel.writeInbound(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/"))); diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpServerUpgradeHandlerTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpServerUpgradeHandlerTest.java index f7835193ff..7870365b57 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpServerUpgradeHandlerTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpServerUpgradeHandlerTest.java @@ -18,16 +18,15 @@ package io.netty.handler.codec.http; import java.util.Collection; import java.util.Collections; +import io.netty.channel.ChannelInboundHandler; import org.junit.Test; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelDuplexHandler; -import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelPromise; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodec; @@ -57,7 +56,7 @@ public class HttpServerUpgradeHandlerTest { assertNotNull(ctx.pipeline().get(HttpServerUpgradeHandler.class)); // Add a marker handler to signal that the upgrade has happened - ctx.pipeline().addAfter(ctx.name(), "marker", new ChannelInboundHandlerAdapter()); + ctx.pipeline().addAfter(ctx.name(), "marker", new ChannelInboundHandler() { }); } } diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java index 0e9c075369..f6a050adcf 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java @@ -17,8 +17,8 @@ package io.netty.handler.codec.http.websocketx; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; -import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; +import io.netty.channel.ChannelOutboundHandler; import io.netty.channel.ChannelPromise; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.handler.codec.http.DefaultFullHttpRequest; @@ -154,7 +154,7 @@ public class WebSocketServerProtocolHandlerTest { return new String(response.content().array()); } - private class MockOutboundHandler extends ChannelOutboundHandlerAdapter { + private class MockOutboundHandler implements ChannelOutboundHandler { @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { @@ -167,7 +167,7 @@ public class WebSocketServerProtocolHandlerTest { } } - private static class CustomTextFrameHandler extends ChannelInboundHandlerAdapter { + private static class CustomTextFrameHandler implements ChannelInboundHandler { private String content; @Override diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/InboundHttpToHttp2Adapter.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/InboundHttpToHttp2Adapter.java index b81c665399..ff3cc1cbb9 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/InboundHttpToHttp2Adapter.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/InboundHttpToHttp2Adapter.java @@ -16,7 +16,7 @@ package io.netty.handler.codec.http2; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.handler.codec.http.FullHttpMessage; import io.netty.handler.codec.http.HttpHeaders; import io.netty.handler.codec.http.HttpScheme; @@ -26,7 +26,7 @@ import io.netty.util.internal.UnstableApi; * Translates HTTP/1.x object reads into HTTP/2 frames. */ @UnstableApi -public class InboundHttpToHttp2Adapter extends ChannelInboundHandlerAdapter { +public class InboundHttpToHttp2Adapter implements ChannelInboundHandler { private final Http2Connection connection; private final Http2FrameListener listener; @@ -45,7 +45,7 @@ public class InboundHttpToHttp2Adapter extends ChannelInboundHandlerAdapter { if (msg instanceof FullHttpMessage) { handle(ctx, connection, listener, (FullHttpMessage) msg); } else { - super.channelRead(ctx, msg); + ctx.fireChannelRead(msg); } } diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/CleartextHttp2ServerUpgradeHandlerTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/CleartextHttp2ServerUpgradeHandlerTest.java index 0ba9769264..d487e2f6ed 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/CleartextHttp2ServerUpgradeHandlerTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/CleartextHttp2ServerUpgradeHandlerTest.java @@ -19,7 +19,7 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.handler.codec.http.DefaultHttpHeaders; @@ -27,7 +27,6 @@ import io.netty.handler.codec.http.HttpMethod; import io.netty.handler.codec.http.HttpRequest; import io.netty.handler.codec.http.HttpServerCodec; import io.netty.handler.codec.http.HttpServerUpgradeHandler; -import io.netty.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodec; import io.netty.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodecFactory; import io.netty.handler.codec.http.HttpServerUpgradeHandler.UpgradeEvent; import io.netty.handler.codec.http.HttpVersion; @@ -79,7 +78,7 @@ public class CleartextHttp2ServerUpgradeHandlerTest { CleartextHttp2ServerUpgradeHandler handler = new CleartextHttp2ServerUpgradeHandler( httpServerCodec, upgradeHandler, http2ConnectionHandler); - channel = new EmbeddedChannel(handler, new ChannelInboundHandlerAdapter() { + channel = new EmbeddedChannel(handler, new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { userEvents.add(evt); @@ -205,7 +204,7 @@ public class CleartextHttp2ServerUpgradeHandlerTest { CleartextHttp2ServerUpgradeHandler handler = new CleartextHttp2ServerUpgradeHandler( httpServerCodec, upgradeHandler, http2Codec); - channel = new EmbeddedChannel(handler, new ChannelInboundHandlerAdapter() { + channel = new EmbeddedChannel(handler, new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { userEvents.add(evt); diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/DataCompressionHttp2Test.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/DataCompressionHttp2Test.java index 66e5dd828b..9e8326254c 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/DataCompressionHttp2Test.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/DataCompressionHttp2Test.java @@ -21,7 +21,7 @@ import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelPromise; @@ -31,7 +31,6 @@ import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.handler.codec.http.HttpHeaderNames; import io.netty.handler.codec.http.HttpHeaderValues; -import io.netty.handler.codec.http2.Http2TestUtil.Http2Runnable; import io.netty.util.AsciiString; import io.netty.util.CharsetUtil; import io.netty.util.NetUtil; @@ -41,8 +40,6 @@ import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -323,7 +320,7 @@ public class DataCompressionHttp2Test { .gracefulShutdownTimeoutMillis(0) .codec(decoder, clientEncoder).build(); p.addLast(clientHandler); - p.addLast(new ChannelInboundHandlerAdapter() { + p.addLast(new ChannelInboundHandler() { public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt == Http2ConnectionPrefaceAndSettingsFrameWrittenEvent.INSTANCE) { prefaceWrittenLatch.countDown(); diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ClientUpgradeCodecTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ClientUpgradeCodecTest.java index 2d381e4f88..4649e8b700 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ClientUpgradeCodecTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ClientUpgradeCodecTest.java @@ -16,7 +16,7 @@ package io.netty.handler.codec.http2; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.handler.codec.http.DefaultFullHttpRequest; import io.netty.handler.codec.http.FullHttpRequest; @@ -44,13 +44,13 @@ public class Http2ClientUpgradeCodecTest { @Test public void testUpgradeToHttp2MultiplexCodec() throws Exception { testUpgrade(Http2MultiplexCodecBuilder.forClient(new HttpInboundHandler()) - .withUpgradeStreamHandler(new ChannelInboundHandlerAdapter()).build()); + .withUpgradeStreamHandler(new ChannelInboundHandler() { }).build()); } private static void testUpgrade(Http2ConnectionHandler handler) throws Exception { FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.OPTIONS, "*"); - EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandlerAdapter()); + EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandler() { }); ChannelHandlerContext ctx = channel.pipeline().firstContext(); Http2ClientUpgradeCodec codec = new Http2ClientUpgradeCodec("connectionHandler", handler); codec.setUpgradeHeaders(ctx, request); @@ -64,5 +64,5 @@ public class Http2ClientUpgradeCodecTest { } @ChannelHandler.Sharable - private static final class HttpInboundHandler extends ChannelInboundHandlerAdapter { } + private static final class HttpInboundHandler implements ChannelInboundHandler { } } diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java index 13d5c274fb..c23a76b66e 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java @@ -25,9 +25,9 @@ import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerAdapter; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; -import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelOutboundHandler; import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelPromise; import io.netty.channel.MultithreadEventLoopGroup; @@ -36,7 +36,6 @@ import io.netty.channel.local.LocalChannel; import io.netty.channel.local.LocalHandler; import io.netty.channel.local.LocalServerChannel; import io.netty.handler.codec.http2.Http2TestUtil.FrameCountDown; -import io.netty.handler.codec.http2.Http2TestUtil.Http2Runnable; import io.netty.util.AsciiString; import io.netty.util.IllegalReferenceCountException; import io.netty.util.ReferenceCountUtil; @@ -643,7 +642,7 @@ public class Http2ConnectionRoundtripTest { runInChannel(clientChannel, () -> { http2Client.encoder().writeHeaders(ctx(), 3, EmptyHttp2Headers.INSTANCE, 0, (short) 16, false, 0, false, newPromise()); - clientChannel.pipeline().addFirst(new ChannelOutboundHandlerAdapter() { + clientChannel.pipeline().addFirst(new ChannelOutboundHandler() { @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { ReferenceCountUtil.release(msg); @@ -1062,7 +1061,7 @@ public class Http2ConnectionRoundtripTest { .validateHeaders(false) .gracefulShutdownTimeoutMillis(0) .build()); - p.addLast(new ChannelInboundHandlerAdapter() { + p.addLast(new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt == Http2ConnectionPrefaceAndSettingsFrameWrittenEvent.INSTANCE) { diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameCodecTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameCodecTest.java index 6f43827a94..28744cfbbf 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameCodecTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameCodecTest.java @@ -19,7 +19,7 @@ import io.netty.buffer.Unpooled; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelPromise; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.handler.codec.UnsupportedMessageTypeException; @@ -779,7 +779,7 @@ public class Http2FrameCodecTest { @Test public void upgradeWithoutFlowControlling() throws Exception { - channel.pipeline().addAfter(frameCodec.ctx.name(), null, new ChannelInboundHandlerAdapter() { + channel.pipeline().addAfter(frameCodec.ctx.name(), null, new ChannelInboundHandler() { @Override public void channelRead(final ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof Http2DataFrame) { diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameInboundWriter.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameInboundWriter.java index 586ac71877..609026eac8 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameInboundWriter.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameInboundWriter.java @@ -22,7 +22,7 @@ import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelOutboundHandler; import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelProgressivePromise; import io.netty.channel.ChannelPromise; @@ -106,8 +106,8 @@ final class Http2FrameInboundWriter { writer.writeFrame(ctx, frameType, streamId, flags, payload, ctx.newPromise()).syncUninterruptibly(); } - private static final class WriteInboundChannelHandlerContext extends ChannelOutboundHandlerAdapter - implements ChannelHandlerContext { + private static final class WriteInboundChannelHandlerContext + implements ChannelHandlerContext, ChannelOutboundHandler { private final EmbeddedChannel channel; WriteInboundChannelHandlerContext(EmbeddedChannel channel) { diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexCodecBuilderTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexCodecBuilderTest.java index 3da7aa90ea..29d76f6627 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexCodecBuilderTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexCodecBuilderTest.java @@ -25,7 +25,7 @@ import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandler.Sharable; import io.netty.channel.ChannelHandlerAdapter; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.EventLoopGroup; import io.netty.channel.MultithreadEventLoopGroup; @@ -81,25 +81,25 @@ public class Http2MultiplexCodecBuilderTest { @Override protected void initChannel(Channel ch) throws Exception { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { private boolean writable; @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { writable |= ctx.channel().isWritable(); - super.channelActive(ctx); + ctx.fireChannelActive(); } @Override public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception { writable |= ctx.channel().isWritable(); - super.channelWritabilityChanged(ctx); + ctx.fireChannelWritabilityChanged(); } @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { assertTrue(writable); - super.channelInactive(ctx); + ctx.fireChannelInactive(); } }); ch.pipeline().addLast(serverLastInboundHandler); diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexCodecClientUpgradeTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexCodecClientUpgradeTest.java index 26b63ed7f9..95bdabae61 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexCodecClientUpgradeTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexCodecClientUpgradeTest.java @@ -14,11 +14,11 @@ */ package io.netty.handler.codec.http2; +import io.netty.channel.ChannelInboundHandler; import org.junit.Test; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.embedded.EmbeddedChannel; import static org.junit.Assert.assertEquals; @@ -28,14 +28,14 @@ import static org.junit.Assert.assertTrue; public class Http2MultiplexCodecClientUpgradeTest { @ChannelHandler.Sharable - private final class NoopHandler extends ChannelInboundHandlerAdapter { + private final class NoopHandler implements ChannelInboundHandler { @Override public void channelActive(ChannelHandlerContext ctx) { ctx.channel().close(); } } - private final class UpgradeHandler extends ChannelInboundHandlerAdapter { + private final class UpgradeHandler implements ChannelInboundHandler { Http2Stream.State stateOnActive; int streamId; @@ -44,7 +44,7 @@ public class Http2MultiplexCodecClientUpgradeTest { Http2StreamChannel ch = (Http2StreamChannel) ctx.channel(); stateOnActive = ch.stream().state(); streamId = ch.stream().id(); - super.channelActive(ctx); + ctx.fireChannelActive(); } } diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexCodecTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexCodecTest.java index f33b16abe1..6f7f07d8d0 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexCodecTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexCodecTest.java @@ -21,7 +21,7 @@ import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelPromise; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.handler.codec.http.HttpMethod; @@ -33,7 +33,6 @@ import io.netty.util.AttributeKey; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.mockito.ArgumentMatcher; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -133,7 +132,7 @@ public class Http2MultiplexCodecTest { @Test public void writeUnknownFrame() { - Http2StreamChannel childChannel = newOutboundStream(new ChannelInboundHandlerAdapter() { + Http2StreamChannel childChannel = newOutboundStream(new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) { ctx.writeAndFlush(new DefaultHttp2HeadersFrame(new DefaultHttp2Headers())); @@ -157,7 +156,7 @@ public class Http2MultiplexCodecTest { AtomicInteger maxReads, final ChannelHandler childHandler) { final AtomicReference streamChannelRef = new AtomicReference<>(); childChannelInitializer.maxReads = maxReads; - childChannelInitializer.handler = new ChannelInboundHandlerAdapter() { + childChannelInitializer.handler = new ChannelInboundHandler() { @Override public void channelRegistered(ChannelHandlerContext ctx) { assertNull(streamChannelRef.get()); @@ -184,7 +183,7 @@ public class Http2MultiplexCodecTest { // header frame and unknown frame verifyFramesMultiplexedToCorrectChannel(channel, handler, 2); - Channel childChannel = newOutboundStream(new ChannelInboundHandlerAdapter()); + Channel childChannel = newOutboundStream(new ChannelInboundHandler() { }); assertTrue(childChannel.isActive()); } @@ -310,7 +309,7 @@ public class Http2MultiplexCodecTest { assertNotNull(headersFrame); // Add a handler which will request reads. - childChannel.pipeline().addFirst(new ChannelInboundHandlerAdapter() { + childChannel.pipeline().addFirst(new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) { ctx.fireChannelRead(msg); @@ -364,7 +363,7 @@ public class Http2MultiplexCodecTest { @Test public void outboundStreamShouldWriteResetFrameOnClose_headersSent() { - ChannelHandler handler = new ChannelInboundHandlerAdapter() { + ChannelHandler handler = new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) { ctx.writeAndFlush(new DefaultHttp2HeadersFrame(new DefaultHttp2Headers())); @@ -399,7 +398,7 @@ public class Http2MultiplexCodecTest { } }); - Http2StreamChannel childChannel = newOutboundStream(new ChannelInboundHandlerAdapter() { + Http2StreamChannel childChannel = newOutboundStream(new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) { ctx.writeAndFlush(new DefaultHttp2HeadersFrame(new DefaultHttp2Headers())); @@ -630,7 +629,7 @@ public class Http2MultiplexCodecTest { public void settingChannelOptsAndAttrs() { AttributeKey key = AttributeKey.newInstance("foo"); - Channel childChannel = newOutboundStream(new ChannelInboundHandlerAdapter()); + Channel childChannel = newOutboundStream(new ChannelInboundHandler() { }); childChannel.config().setAutoRead(false).setWriteSpinCount(1000); childChannel.attr(key).set("bar"); assertFalse(childChannel.config().isAutoRead()); @@ -640,7 +639,7 @@ public class Http2MultiplexCodecTest { @Test public void outboundFlowControlWritability() { - Http2StreamChannel childChannel = newOutboundStream(new ChannelInboundHandlerAdapter()); + Http2StreamChannel childChannel = newOutboundStream(new ChannelInboundHandler() { }); assertTrue(childChannel.isActive()); assertTrue(childChannel.isWritable()); @@ -692,13 +691,13 @@ public class Http2MultiplexCodecTest { assertTrue(childChannel.isOpen()); assertTrue(childChannel.isActive()); - childChannel.pipeline().addLast(new ChannelInboundHandlerAdapter() { + childChannel.pipeline().addLast(new ChannelInboundHandler() { @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { channelOpen.set(ctx.channel().isOpen()); channelActive.set(ctx.channel().isActive()); - super.channelInactive(ctx); + ctx.fireChannelInactive(); } }); @@ -713,7 +712,7 @@ public class Http2MultiplexCodecTest { final AtomicInteger exceptionCaught = new AtomicInteger(-1); final AtomicInteger channelInactive = new AtomicInteger(-1); final AtomicInteger channelUnregistered = new AtomicInteger(-1); - Http2StreamChannel childChannel = newOutboundStream(new ChannelInboundHandlerAdapter() { + Http2StreamChannel childChannel = newOutboundStream(new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { @@ -722,24 +721,24 @@ public class Http2MultiplexCodecTest { } }); - childChannel.pipeline().addLast(new ChannelInboundHandlerAdapter() { + childChannel.pipeline().addLast(new ChannelInboundHandler() { @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { channelInactive.set(count.getAndIncrement()); - super.channelInactive(ctx); + ctx.fireChannelInactive(); } @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { exceptionCaught.set(count.getAndIncrement()); - super.exceptionCaught(ctx, cause); + ctx.fireExceptionCaught(cause); } @Override public void channelUnregistered(ChannelHandlerContext ctx) throws Exception { channelUnregistered.set(count.getAndIncrement()); - super.channelUnregistered(ctx); + ctx.fireChannelUnregistered(); } }); @@ -785,7 +784,7 @@ public class Http2MultiplexCodecTest { assertEquals(new DefaultHttp2HeadersFrame(request).stream(childChannel.stream()), inboundHandler.readInbound()); - ChannelHandler readCompleteSupressHandler = new ChannelInboundHandlerAdapter() { + ChannelHandler readCompleteSupressHandler = new ChannelInboundHandler() { @Override public void channelReadComplete(ChannelHandlerContext ctx) { // We want to simulate the parent channel calling channelRead and delay calling channelReadComplete. @@ -848,7 +847,7 @@ public class Http2MultiplexCodecTest { assertEquals(new DefaultHttp2HeadersFrame(request).stream(childChannel.stream()), inboundHandler.readInbound()); - ChannelHandler readCompleteSupressHandler = new ChannelInboundHandlerAdapter() { + ChannelHandler readCompleteSupressHandler = new ChannelInboundHandler() { @Override public void channelReadComplete(ChannelHandlerContext ctx) { // We want to simulate the parent channel calling channelRead and delay calling channelReadComplete. @@ -908,7 +907,7 @@ public class Http2MultiplexCodecTest { assertEquals(new DefaultHttp2HeadersFrame(request).stream(childChannel.stream()), inboundHandler.readInbound()); - ChannelHandler readCompleteSupressHandler = new ChannelInboundHandlerAdapter() { + ChannelHandler readCompleteSupressHandler = new ChannelInboundHandler() { @Override public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { // We want to simulate the parent channel calling channelRead and delay calling channelReadComplete. diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ServerUpgradeCodecTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ServerUpgradeCodecTest.java index fe93b6b791..d2423d1b42 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ServerUpgradeCodecTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ServerUpgradeCodecTest.java @@ -17,7 +17,7 @@ package io.netty.handler.codec.http2; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.handler.codec.http.DefaultFullHttpRequest; import io.netty.handler.codec.http.DefaultHttpHeaders; @@ -57,7 +57,7 @@ public class Http2ServerUpgradeCodecTest { request.headers().set(HttpHeaderNames.UPGRADE, "h2c"); request.headers().set("HTTP2-Settings", "AAMAAABkAAQAAP__"); - EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandlerAdapter()); + EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandler() { }); ChannelHandlerContext ctx = channel.pipeline().firstContext(); Http2ServerUpgradeCodec codec = new Http2ServerUpgradeCodec("connectionHandler", handler); assertTrue(codec.prepareUpgradeResponse(ctx, request, new DefaultHttpHeaders())); @@ -78,5 +78,5 @@ public class Http2ServerUpgradeCodecTest { } @ChannelHandler.Sharable - private static final class HttpInboundHandler extends ChannelInboundHandlerAdapter { } + private static final class HttpInboundHandler implements ChannelInboundHandler { } } diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2StreamFrameToHttpObjectCodecTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2StreamFrameToHttpObjectCodecTest.java index e04c6db56d..30d89bb510 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2StreamFrameToHttpObjectCodecTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2StreamFrameToHttpObjectCodecTest.java @@ -21,7 +21,7 @@ import io.netty.buffer.ByteBufAllocator; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelOutboundHandler; import io.netty.channel.ChannelPromise; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.handler.codec.EncoderException; @@ -450,7 +450,7 @@ public class Http2StreamFrameToHttpObjectCodecTest { final SslContext ctx = SslContextBuilder.forClient().sslProvider(SslProvider.JDK).build(); EmbeddedChannel ch = new EmbeddedChannel(ctx.newHandler(ByteBufAllocator.DEFAULT), - new ChannelOutboundHandlerAdapter() { + new ChannelOutboundHandler() { @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (msg instanceof Http2StreamFrame) { @@ -880,7 +880,7 @@ public class Http2StreamFrameToHttpObjectCodecTest { final SslContext ctx = SslContextBuilder.forClient().sslProvider(SslProvider.JDK).build(); EmbeddedChannel tlsCh = new EmbeddedChannel(ctx.newHandler(ByteBufAllocator.DEFAULT), - new ChannelOutboundHandlerAdapter() { + new ChannelOutboundHandler() { @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) { if (msg instanceof Http2StreamFrame) { @@ -893,7 +893,7 @@ public class Http2StreamFrameToHttpObjectCodecTest { }, sharedHandler); EmbeddedChannel plaintextCh = new EmbeddedChannel( - new ChannelOutboundHandlerAdapter() { + new ChannelOutboundHandler() { @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) { if (msg instanceof Http2StreamFrame) { diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/HttpToHttp2ConnectionHandlerTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/HttpToHttp2ConnectionHandlerTest.java index d19e720384..8628ecfe85 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/HttpToHttp2ConnectionHandlerTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/HttpToHttp2ConnectionHandlerTest.java @@ -21,7 +21,7 @@ import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelPromise; @@ -529,7 +529,7 @@ public class HttpToHttp2ConnectionHandlerTest { .gracefulShutdownTimeoutMillis(0) .build(); p.addLast(handler); - p.addLast(new ChannelInboundHandlerAdapter() { + p.addLast(new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt == Http2ConnectionPrefaceAndSettingsFrameWrittenEvent.INSTANCE) { diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/InboundHttp2ToHttpAdapterTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/InboundHttp2ToHttpAdapterTest.java index fee36fe62b..e0ee295559 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/InboundHttp2ToHttpAdapterTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/InboundHttp2ToHttpAdapterTest.java @@ -21,7 +21,7 @@ import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelPromise; @@ -665,7 +665,7 @@ public class InboundHttp2ToHttpAdapterTest { clientDelegator = new HttpResponseDelegator(clientListener, clientLatch, clientLatch2); p.addLast(clientDelegator); - p.addLast(new ChannelInboundHandlerAdapter() { + p.addLast(new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { Http2Exception e = getEmbeddedHttp2Exception(cause); @@ -673,11 +673,11 @@ public class InboundHttp2ToHttpAdapterTest { clientException = e; clientLatch.countDown(); } else { - super.exceptionCaught(ctx, cause); + ctx.fireExceptionCaught(cause); } } }); - p.addLast(new ChannelInboundHandlerAdapter() { + p.addLast(new ChannelInboundHandler() { public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt == Http2ConnectionPrefaceAndSettingsFrameWrittenEvent.INSTANCE) { prefaceWrittenLatch.countDown(); diff --git a/codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java b/codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java index 3f3fe59981..38f55858fc 100644 --- a/codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java +++ b/codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java @@ -22,15 +22,16 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import io.netty.buffer.CompositeByteBuf; import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandlerAdapter; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.socket.ChannelInputShutdownEvent; import io.netty.util.internal.StringUtil; import java.util.List; /** - * {@link ChannelInboundHandlerAdapter} which decodes bytes in a stream-like fashion from one {@link ByteBuf} to an + * {@link ChannelInboundHandler} which decodes bytes in a stream-like fashion from one {@link ByteBuf} to an * other Message type. * * For example here is an implementation which reads all readable bytes from @@ -70,7 +71,7 @@ import java.util.List; * is not released or added to the out {@link List}. Use derived buffers like {@link ByteBuf#readSlice(int)} * to avoid leaking memory. */ -public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter { +public abstract class ByteToMessageDecoder extends ChannelHandlerAdapter implements ChannelInboundHandler { /** * Cumulate {@link ByteBuf}s by merge them into one {@link ByteBuf}'s, using memory copies. @@ -356,7 +357,7 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter // when the input has been shutdown. channelInputClosed(ctx, false); } - super.userEventTriggered(ctx, evt); + ctx.fireUserEventTriggered(evt); } private void channelInputClosed(ChannelHandlerContext ctx, boolean callChannelInactive) throws Exception { diff --git a/codec/src/main/java/io/netty/handler/codec/MessageToByteEncoder.java b/codec/src/main/java/io/netty/handler/codec/MessageToByteEncoder.java index b23381265f..40ddcf9776 100644 --- a/codec/src/main/java/io/netty/handler/codec/MessageToByteEncoder.java +++ b/codec/src/main/java/io/netty/handler/codec/MessageToByteEncoder.java @@ -17,9 +17,9 @@ package io.netty.handler.codec; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandlerAdapter; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelOutboundHandler; -import io.netty.channel.ChannelOutboundHandlerAdapter; import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelPromise; import io.netty.util.ReferenceCountUtil; @@ -27,7 +27,7 @@ import io.netty.util.internal.TypeParameterMatcher; /** - * {@link ChannelOutboundHandlerAdapter} which encodes message in a stream-like fashion from one message to an + * {@link ChannelOutboundHandler} which encodes message in a stream-like fashion from one message to an * {@link ByteBuf}. * * @@ -43,7 +43,7 @@ import io.netty.util.internal.TypeParameterMatcher; * } * */ -public abstract class MessageToByteEncoder extends ChannelOutboundHandlerAdapter { +public abstract class MessageToByteEncoder extends ChannelHandlerAdapter implements ChannelOutboundHandler { private final TypeParameterMatcher matcher; private final boolean preferDirect; diff --git a/codec/src/main/java/io/netty/handler/codec/MessageToMessageDecoder.java b/codec/src/main/java/io/netty/handler/codec/MessageToMessageDecoder.java index ec828e2e32..8ca99d46b8 100644 --- a/codec/src/main/java/io/netty/handler/codec/MessageToMessageDecoder.java +++ b/codec/src/main/java/io/netty/handler/codec/MessageToMessageDecoder.java @@ -15,9 +15,9 @@ */ package io.netty.handler.codec; +import io.netty.channel.ChannelHandlerAdapter; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandler; -import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelPipeline; import io.netty.util.ReferenceCountUtil; import io.netty.util.ReferenceCounted; @@ -26,7 +26,7 @@ import io.netty.util.internal.TypeParameterMatcher; import java.util.List; /** - * {@link ChannelInboundHandlerAdapter} which decodes from one message to an other message. + * {@link ChannelInboundHandler} which decodes from one message to an other message. * * * For example here is an implementation which decodes a {@link String} to an {@link Integer} which represent @@ -49,7 +49,7 @@ import java.util.List; * {@link ReferenceCounted#release()} on decoded messages. * */ -public abstract class MessageToMessageDecoder extends ChannelInboundHandlerAdapter { +public abstract class MessageToMessageDecoder extends ChannelHandlerAdapter implements ChannelInboundHandler { private final TypeParameterMatcher matcher; diff --git a/codec/src/main/java/io/netty/handler/codec/MessageToMessageEncoder.java b/codec/src/main/java/io/netty/handler/codec/MessageToMessageEncoder.java index 439dc8cb19..6649663e30 100644 --- a/codec/src/main/java/io/netty/handler/codec/MessageToMessageEncoder.java +++ b/codec/src/main/java/io/netty/handler/codec/MessageToMessageEncoder.java @@ -15,9 +15,9 @@ */ package io.netty.handler.codec; +import io.netty.channel.ChannelHandlerAdapter; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelOutboundHandler; -import io.netty.channel.ChannelOutboundHandlerAdapter; import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelPromise; import io.netty.util.ReferenceCountUtil; @@ -29,7 +29,7 @@ import io.netty.util.internal.TypeParameterMatcher; import java.util.List; /** - * {@link ChannelOutboundHandlerAdapter} which encodes from one message to an other message + * {@link ChannelOutboundHandler} which encodes from one message to an other message * * For example here is an implementation which decodes an {@link Integer} to an {@link String}. * @@ -49,7 +49,7 @@ import java.util.List; * are of type {@link ReferenceCounted}. This is needed as the {@link MessageToMessageEncoder} will call * {@link ReferenceCounted#release()} on encoded messages. */ -public abstract class MessageToMessageEncoder extends ChannelOutboundHandlerAdapter { +public abstract class MessageToMessageEncoder extends ChannelHandlerAdapter implements ChannelOutboundHandler { private final TypeParameterMatcher matcher; diff --git a/codec/src/test/java/io/netty/handler/codec/ByteToMessageDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/ByteToMessageDecoderTest.java index defa801c92..2fbc475a6c 100644 --- a/codec/src/test/java/io/netty/handler/codec/ByteToMessageDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/ByteToMessageDecoderTest.java @@ -21,7 +21,7 @@ import io.netty.buffer.Unpooled; import io.netty.buffer.UnpooledByteBufAllocator; import io.netty.buffer.UnpooledHeapByteBuf; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.embedded.EmbeddedChannel; import org.junit.Test; @@ -174,7 +174,7 @@ public class ByteToMessageDecoderTest { assertFalse(in.isReadable()); out.add("data"); } - }, new ChannelInboundHandlerAdapter() { + }, new ChannelInboundHandler() { @Override public void channelInactive(ChannelHandlerContext ctx) { queue.add(3); @@ -212,7 +212,7 @@ public class ByteToMessageDecoderTest { } }; - EmbeddedChannel channel = new EmbeddedChannel(decoder, new ChannelInboundHandlerAdapter() { + EmbeddedChannel channel = new EmbeddedChannel(decoder, new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) { if (msg == upgradeMessage) { diff --git a/codec/src/test/java/io/netty/handler/codec/MessageAggregatorTest.java b/codec/src/test/java/io/netty/handler/codec/MessageAggregatorTest.java index d3c4f5f6c9..d9647855b2 100644 --- a/codec/src/test/java/io/netty/handler/codec/MessageAggregatorTest.java +++ b/codec/src/test/java/io/netty/handler/codec/MessageAggregatorTest.java @@ -16,6 +16,7 @@ package io.netty.handler.codec; +import io.netty.channel.ChannelOutboundHandler; import org.junit.Test; import static org.junit.Assert.*; @@ -26,12 +27,11 @@ import io.netty.buffer.ByteBufHolder; import io.netty.buffer.DefaultByteBufHolder; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelOutboundHandlerAdapter; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.util.CharsetUtil; public class MessageAggregatorTest { - private static final class ReadCounter extends ChannelOutboundHandlerAdapter { + private static final class ReadCounter implements ChannelOutboundHandler { int value; @Override diff --git a/codec/src/test/java/io/netty/handler/codec/MessageToMessageEncoderTest.java b/codec/src/test/java/io/netty/handler/codec/MessageToMessageEncoderTest.java index 2d09725af0..fb4fccb35f 100644 --- a/codec/src/test/java/io/netty/handler/codec/MessageToMessageEncoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/MessageToMessageEncoderTest.java @@ -18,7 +18,7 @@ package io.netty.handler.codec; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelOutboundHandler; import io.netty.channel.ChannelPromise; import io.netty.channel.embedded.EmbeddedChannel; import org.junit.Test; @@ -55,7 +55,7 @@ public class MessageToMessageEncoderTest { final Exception firstWriteException = new Exception(); - ChannelHandler writeThrower = new ChannelOutboundHandlerAdapter() { + ChannelHandler writeThrower = new ChannelOutboundHandler() { private boolean firstWritten; @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) { diff --git a/codec/src/test/java/io/netty/handler/codec/ReplayingDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/ReplayingDecoderTest.java index 23cfe02595..34c95bbea7 100644 --- a/codec/src/test/java/io/netty/handler/codec/ReplayingDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/ReplayingDecoderTest.java @@ -18,7 +18,7 @@ package io.netty.handler.codec; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.channel.socket.ChannelInputShutdownEvent; import org.junit.Test; @@ -96,7 +96,7 @@ public class ReplayingDecoderTest { assertNull(ch.readInbound()); } - private static final class BloatedLineDecoder extends ChannelInboundHandlerAdapter { + private static final class BloatedLineDecoder implements ChannelInboundHandler { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { ctx.pipeline().replace(this, "less-bloated", new LineDecoder()); @@ -226,7 +226,7 @@ public class ReplayingDecoderTest { assertFalse(in.isReadable()); out.add("data"); } - }, new ChannelInboundHandlerAdapter() { + }, new ChannelInboundHandler() { @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { queue.add(3); diff --git a/example/src/main/java/io/netty/example/echo/EchoClientHandler.java b/example/src/main/java/io/netty/example/echo/EchoClientHandler.java index 1bab895236..08f2d2b899 100644 --- a/example/src/main/java/io/netty/example/echo/EchoClientHandler.java +++ b/example/src/main/java/io/netty/example/echo/EchoClientHandler.java @@ -18,14 +18,14 @@ package io.netty.example.echo; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; /** * Handler implementation for the echo client. It initiates the ping-pong * traffic between the echo client and server by sending the first message to * the server. */ -public class EchoClientHandler extends ChannelInboundHandlerAdapter { +public class EchoClientHandler implements ChannelInboundHandler { private final ByteBuf firstMessage; diff --git a/example/src/main/java/io/netty/example/echo/EchoServerHandler.java b/example/src/main/java/io/netty/example/echo/EchoServerHandler.java index 095e2c3a20..c169d22c87 100644 --- a/example/src/main/java/io/netty/example/echo/EchoServerHandler.java +++ b/example/src/main/java/io/netty/example/echo/EchoServerHandler.java @@ -17,13 +17,13 @@ package io.netty.example.echo; import io.netty.channel.ChannelHandler.Sharable; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; /** * Handler implementation for the echo server. */ @Sharable -public class EchoServerHandler extends ChannelInboundHandlerAdapter { +public class EchoServerHandler implements ChannelInboundHandler { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) { diff --git a/example/src/main/java/io/netty/example/http2/helloworld/client/Http2ClientInitializer.java b/example/src/main/java/io/netty/example/http2/helloworld/client/Http2ClientInitializer.java index 182c156504..b6c8e2c89d 100644 --- a/example/src/main/java/io/netty/example/http2/helloworld/client/Http2ClientInitializer.java +++ b/example/src/main/java/io/netty/example/http2/helloworld/client/Http2ClientInitializer.java @@ -15,7 +15,7 @@ package io.netty.example.http2.helloworld.client; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; import io.netty.channel.socket.SocketChannel; @@ -129,7 +129,7 @@ public class Http2ClientInitializer extends ChannelInitializer { /** * A handler that triggers the cleartext upgrade to HTTP/2 by sending an initial HTTP request. */ - private final class UpgradeRequestHandler extends ChannelInboundHandlerAdapter { + private final class UpgradeRequestHandler implements ChannelInboundHandler { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { DefaultFullHttpRequest upgradeRequest = @@ -148,7 +148,7 @@ public class Http2ClientInitializer extends ChannelInitializer { /** * Class that logs any User Events triggered on this channel. */ - private static class UserEventLogger extends ChannelInboundHandlerAdapter { + private static class UserEventLogger implements ChannelInboundHandler { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { System.out.println("User Event Triggered: " + evt); diff --git a/example/src/main/java/io/netty/example/http2/helloworld/frame/server/Http2ServerInitializer.java b/example/src/main/java/io/netty/example/http2/helloworld/frame/server/Http2ServerInitializer.java index af42a8e688..1b9c076e2d 100644 --- a/example/src/main/java/io/netty/example/http2/helloworld/frame/server/Http2ServerInitializer.java +++ b/example/src/main/java/io/netty/example/http2/helloworld/frame/server/Http2ServerInitializer.java @@ -17,7 +17,7 @@ package io.netty.example.http2.helloworld.frame.server; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; import io.netty.channel.SimpleChannelInboundHandler; @@ -27,7 +27,6 @@ import io.netty.handler.codec.http.HttpMessage; import io.netty.handler.codec.http.HttpObjectAggregator; import io.netty.handler.codec.http.HttpServerCodec; import io.netty.handler.codec.http.HttpServerUpgradeHandler; -import io.netty.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodec; import io.netty.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodecFactory; import io.netty.handler.codec.http2.Http2CodecUtil; import io.netty.handler.codec.http2.Http2FrameCodecBuilder; @@ -110,7 +109,7 @@ public class Http2ServerInitializer extends ChannelInitializer { /** * Class that logs any User Events triggered on this channel. */ - private static class UserEventLogger extends ChannelInboundHandlerAdapter { + private static class UserEventLogger implements ChannelInboundHandler { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { System.out.println("User Event Triggered: " + evt); diff --git a/example/src/main/java/io/netty/example/http2/helloworld/multiplex/server/Http2ServerInitializer.java b/example/src/main/java/io/netty/example/http2/helloworld/multiplex/server/Http2ServerInitializer.java index a1c3ea607f..ec151ee3c0 100644 --- a/example/src/main/java/io/netty/example/http2/helloworld/multiplex/server/Http2ServerInitializer.java +++ b/example/src/main/java/io/netty/example/http2/helloworld/multiplex/server/Http2ServerInitializer.java @@ -17,7 +17,7 @@ package io.netty.example.http2.helloworld.multiplex.server; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; import io.netty.channel.SimpleChannelInboundHandler; @@ -27,7 +27,6 @@ import io.netty.handler.codec.http.HttpMessage; import io.netty.handler.codec.http.HttpObjectAggregator; import io.netty.handler.codec.http.HttpServerCodec; import io.netty.handler.codec.http.HttpServerUpgradeHandler; -import io.netty.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodec; import io.netty.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodecFactory; import io.netty.handler.codec.http2.Http2MultiplexCodecBuilder; import io.netty.handler.codec.http2.Http2CodecUtil; @@ -110,7 +109,7 @@ public class Http2ServerInitializer extends ChannelInitializer { /** * Class that logs any User Events triggered on this channel. */ - private static class UserEventLogger extends ChannelInboundHandlerAdapter { + private static class UserEventLogger implements ChannelInboundHandler { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { System.out.println("User Event Triggered: " + evt); diff --git a/example/src/main/java/io/netty/example/http2/helloworld/server/Http2ServerInitializer.java b/example/src/main/java/io/netty/example/http2/helloworld/server/Http2ServerInitializer.java index 911dc23d8c..148a846221 100644 --- a/example/src/main/java/io/netty/example/http2/helloworld/server/Http2ServerInitializer.java +++ b/example/src/main/java/io/netty/example/http2/helloworld/server/Http2ServerInitializer.java @@ -17,7 +17,7 @@ package io.netty.example.http2.helloworld.server; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; import io.netty.channel.SimpleChannelInboundHandler; @@ -26,7 +26,6 @@ import io.netty.handler.codec.http.HttpMessage; import io.netty.handler.codec.http.HttpObjectAggregator; import io.netty.handler.codec.http.HttpServerCodec; import io.netty.handler.codec.http.HttpServerUpgradeHandler; -import io.netty.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodec; import io.netty.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodecFactory; import io.netty.handler.codec.http2.CleartextHttp2ServerUpgradeHandler; import io.netty.handler.codec.http2.Http2CodecUtil; @@ -111,7 +110,7 @@ public class Http2ServerInitializer extends ChannelInitializer { /** * Class that logs any User Events triggered on this channel. */ - private static class UserEventLogger extends ChannelInboundHandlerAdapter { + private static class UserEventLogger implements ChannelInboundHandler { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { System.out.println("User Event Triggered: " + evt); diff --git a/example/src/main/java/io/netty/example/localecho/LocalEchoServerHandler.java b/example/src/main/java/io/netty/example/localecho/LocalEchoServerHandler.java index af2d609775..4abf8b028e 100644 --- a/example/src/main/java/io/netty/example/localecho/LocalEchoServerHandler.java +++ b/example/src/main/java/io/netty/example/localecho/LocalEchoServerHandler.java @@ -16,9 +16,9 @@ package io.netty.example.localecho; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; -public class LocalEchoServerHandler extends ChannelInboundHandlerAdapter { +public class LocalEchoServerHandler implements ChannelInboundHandler { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) { diff --git a/example/src/main/java/io/netty/example/objectecho/ObjectEchoClientHandler.java b/example/src/main/java/io/netty/example/objectecho/ObjectEchoClientHandler.java index 43d4db7ce2..8f13b13717 100644 --- a/example/src/main/java/io/netty/example/objectecho/ObjectEchoClientHandler.java +++ b/example/src/main/java/io/netty/example/objectecho/ObjectEchoClientHandler.java @@ -16,7 +16,7 @@ package io.netty.example.objectecho; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import java.util.ArrayList; import java.util.List; @@ -26,7 +26,7 @@ import java.util.List; * ping-pong traffic between the object echo client and server by sending the * first message to the server. */ -public class ObjectEchoClientHandler extends ChannelInboundHandlerAdapter { +public class ObjectEchoClientHandler implements ChannelInboundHandler { private final List firstMessage; diff --git a/example/src/main/java/io/netty/example/objectecho/ObjectEchoServerHandler.java b/example/src/main/java/io/netty/example/objectecho/ObjectEchoServerHandler.java index 151abd3110..f78e5978f1 100644 --- a/example/src/main/java/io/netty/example/objectecho/ObjectEchoServerHandler.java +++ b/example/src/main/java/io/netty/example/objectecho/ObjectEchoServerHandler.java @@ -16,13 +16,13 @@ package io.netty.example.objectecho; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; /** * Handles both client-side and server-side handler depending on which * constructor was called. */ -public class ObjectEchoServerHandler extends ChannelInboundHandlerAdapter { +public class ObjectEchoServerHandler implements ChannelInboundHandler { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) { diff --git a/example/src/main/java/io/netty/example/ocsp/OcspClientExample.java b/example/src/main/java/io/netty/example/ocsp/OcspClientExample.java index 809db41e46..6a87b545e6 100644 --- a/example/src/main/java/io/netty/example/ocsp/OcspClientExample.java +++ b/example/src/main/java/io/netty/example/ocsp/OcspClientExample.java @@ -21,6 +21,7 @@ import java.math.BigInteger; import javax.net.ssl.SSLSession; import javax.security.cert.X509Certificate; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.MultithreadEventLoopGroup; import io.netty.channel.nio.NioHandler; import org.bouncycastle.asn1.ocsp.OCSPResponseStatus; @@ -33,7 +34,6 @@ import io.netty.bootstrap.Bootstrap; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelOption; import io.netty.channel.ChannelPipeline; @@ -152,7 +152,7 @@ public class OcspClientExample { }; } - private static class HttpClientHandler extends ChannelInboundHandlerAdapter { + private static class HttpClientHandler implements ChannelInboundHandler { private final String host; diff --git a/example/src/main/java/io/netty/example/proxy/HexDumpProxyBackendHandler.java b/example/src/main/java/io/netty/example/proxy/HexDumpProxyBackendHandler.java index 0b8aa42bad..4ec3c9404b 100644 --- a/example/src/main/java/io/netty/example/proxy/HexDumpProxyBackendHandler.java +++ b/example/src/main/java/io/netty/example/proxy/HexDumpProxyBackendHandler.java @@ -16,12 +16,11 @@ package io.netty.example.proxy; import io.netty.channel.Channel; -import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; -public class HexDumpProxyBackendHandler extends ChannelInboundHandlerAdapter { +public class HexDumpProxyBackendHandler implements ChannelInboundHandler { private final Channel inboundChannel; diff --git a/example/src/main/java/io/netty/example/proxy/HexDumpProxyFrontendHandler.java b/example/src/main/java/io/netty/example/proxy/HexDumpProxyFrontendHandler.java index 601005b2c5..d3e031cb75 100644 --- a/example/src/main/java/io/netty/example/proxy/HexDumpProxyFrontendHandler.java +++ b/example/src/main/java/io/netty/example/proxy/HexDumpProxyFrontendHandler.java @@ -21,10 +21,10 @@ import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelOption; -public class HexDumpProxyFrontendHandler extends ChannelInboundHandlerAdapter { +public class HexDumpProxyFrontendHandler implements ChannelInboundHandler { private final String remoteHost; private final int remotePort; diff --git a/example/src/main/java/io/netty/example/sctp/SctpEchoClientHandler.java b/example/src/main/java/io/netty/example/sctp/SctpEchoClientHandler.java index 56fe025553..c8b6ae0bfa 100644 --- a/example/src/main/java/io/netty/example/sctp/SctpEchoClientHandler.java +++ b/example/src/main/java/io/netty/example/sctp/SctpEchoClientHandler.java @@ -18,7 +18,7 @@ package io.netty.example.sctp; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.sctp.SctpMessage; /** @@ -26,7 +26,7 @@ import io.netty.channel.sctp.SctpMessage; * traffic between the echo client and server by sending the first message to * the server. */ -public class SctpEchoClientHandler extends ChannelInboundHandlerAdapter { +public class SctpEchoClientHandler implements ChannelInboundHandler { private final ByteBuf firstMessage; diff --git a/example/src/main/java/io/netty/example/sctp/SctpEchoServerHandler.java b/example/src/main/java/io/netty/example/sctp/SctpEchoServerHandler.java index cfacaa74e5..70ab3c122d 100644 --- a/example/src/main/java/io/netty/example/sctp/SctpEchoServerHandler.java +++ b/example/src/main/java/io/netty/example/sctp/SctpEchoServerHandler.java @@ -17,13 +17,13 @@ package io.netty.example.sctp; import io.netty.channel.ChannelHandler.Sharable; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; /** * Handler implementation for the SCTP echo server. */ @Sharable -public class SctpEchoServerHandler extends ChannelInboundHandlerAdapter { +public class SctpEchoServerHandler implements ChannelInboundHandler { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) { diff --git a/example/src/main/java/io/netty/example/socksproxy/DirectClientHandler.java b/example/src/main/java/io/netty/example/socksproxy/DirectClientHandler.java index c143495989..89c52316c0 100644 --- a/example/src/main/java/io/netty/example/socksproxy/DirectClientHandler.java +++ b/example/src/main/java/io/netty/example/socksproxy/DirectClientHandler.java @@ -17,10 +17,10 @@ package io.netty.example.socksproxy; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.util.concurrent.Promise; -public final class DirectClientHandler extends ChannelInboundHandlerAdapter { +public final class DirectClientHandler implements ChannelInboundHandler { private final Promise promise; diff --git a/example/src/main/java/io/netty/example/socksproxy/RelayHandler.java b/example/src/main/java/io/netty/example/socksproxy/RelayHandler.java index f353802a39..2581665053 100644 --- a/example/src/main/java/io/netty/example/socksproxy/RelayHandler.java +++ b/example/src/main/java/io/netty/example/socksproxy/RelayHandler.java @@ -18,10 +18,10 @@ package io.netty.example.socksproxy; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.util.ReferenceCountUtil; -public final class RelayHandler extends ChannelInboundHandlerAdapter { +public final class RelayHandler implements ChannelInboundHandler { private final Channel relayChannel; diff --git a/handler-proxy/src/test/java/io/netty/handler/proxy/HttpProxyHandlerTest.java b/handler-proxy/src/test/java/io/netty/handler/proxy/HttpProxyHandlerTest.java index c6d84cd714..90a7533917 100644 --- a/handler-proxy/src/test/java/io/netty/handler/proxy/HttpProxyHandlerTest.java +++ b/handler-proxy/src/test/java/io/netty/handler/proxy/HttpProxyHandlerTest.java @@ -20,7 +20,7 @@ import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPromise; import io.netty.channel.EventLoopGroup; @@ -186,7 +186,7 @@ public class HttpProxyHandlerTest { @Override protected void initChannel(Channel ch) { ch.pipeline().addFirst(new HttpResponseEncoder()); - ch.pipeline().addFirst(new ChannelInboundHandlerAdapter() { + ch.pipeline().addFirst(new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) { DefaultFullHttpResponse response = new DefaultFullHttpResponse( @@ -205,7 +205,7 @@ public class HttpProxyHandlerTest { @Override protected void initChannel(Channel ch) { ch.pipeline().addFirst(new HttpProxyHandler(addr)); - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { diff --git a/handler-proxy/src/test/java/io/netty/handler/proxy/ProxyServer.java b/handler-proxy/src/test/java/io/netty/handler/proxy/ProxyServer.java index c2122684a1..4020c62e42 100644 --- a/handler-proxy/src/test/java/io/netty/handler/proxy/ProxyServer.java +++ b/handler-proxy/src/test/java/io/netty/handler/proxy/ProxyServer.java @@ -25,7 +25,7 @@ import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; import io.netty.channel.EventLoop; @@ -229,7 +229,7 @@ abstract class ProxyServer { ctx.close(); } - private final class BackendHandler extends ChannelInboundHandlerAdapter { + private final class BackendHandler implements ChannelInboundHandler { private final ChannelHandlerContext frontend; diff --git a/handler/src/main/java/io/netty/handler/ipfilter/AbstractRemoteAddressFilter.java b/handler/src/main/java/io/netty/handler/ipfilter/AbstractRemoteAddressFilter.java index a0a2c1e12d..f11a7a76cc 100644 --- a/handler/src/main/java/io/netty/handler/ipfilter/AbstractRemoteAddressFilter.java +++ b/handler/src/main/java/io/netty/handler/ipfilter/AbstractRemoteAddressFilter.java @@ -19,7 +19,7 @@ import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import java.net.SocketAddress; @@ -35,7 +35,7 @@ import java.net.SocketAddress; * flexibility to respond to rejected (denied) connections. If you do not want to send a response, just have it return * null. Take a look at {@link RuleBasedIpFilter} for details. */ -public abstract class AbstractRemoteAddressFilter extends ChannelInboundHandlerAdapter { +public abstract class AbstractRemoteAddressFilter implements ChannelInboundHandler { @Override public void channelRegistered(ChannelHandlerContext ctx) throws Exception { diff --git a/handler/src/main/java/io/netty/handler/ssl/ApplicationProtocolNegotiationHandler.java b/handler/src/main/java/io/netty/handler/ssl/ApplicationProtocolNegotiationHandler.java index 306f4013fc..2155b3d41e 100644 --- a/handler/src/main/java/io/netty/handler/ssl/ApplicationProtocolNegotiationHandler.java +++ b/handler/src/main/java/io/netty/handler/ssl/ApplicationProtocolNegotiationHandler.java @@ -19,7 +19,7 @@ import static java.util.Objects.requireNonNull; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; import io.netty.util.internal.logging.InternalLogger; @@ -60,7 +60,7 @@ import io.netty.util.internal.logging.InternalLoggerFactory; * } * */ -public abstract class ApplicationProtocolNegotiationHandler extends ChannelInboundHandlerAdapter { +public abstract class ApplicationProtocolNegotiationHandler implements ChannelInboundHandler { private static final InternalLogger logger = InternalLoggerFactory.getInstance(ApplicationProtocolNegotiationHandler.class); diff --git a/handler/src/main/java/io/netty/handler/ssl/ocsp/OcspClientHandler.java b/handler/src/main/java/io/netty/handler/ssl/ocsp/OcspClientHandler.java index 5088c1ead2..a802f4b145 100644 --- a/handler/src/main/java/io/netty/handler/ssl/ocsp/OcspClientHandler.java +++ b/handler/src/main/java/io/netty/handler/ssl/ocsp/OcspClientHandler.java @@ -18,7 +18,7 @@ package io.netty.handler.ssl.ocsp; import static java.util.Objects.requireNonNull; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.handler.ssl.ReferenceCountedOpenSslContext; import io.netty.handler.ssl.ReferenceCountedOpenSslEngine; import io.netty.handler.ssl.SslHandshakeCompletionEvent; @@ -34,7 +34,7 @@ import javax.net.ssl.SSLHandshakeException; * @see ReferenceCountedOpenSslEngine#getOcspResponse() */ @UnstableApi -public abstract class OcspClientHandler extends ChannelInboundHandlerAdapter { +public abstract class OcspClientHandler implements ChannelInboundHandler { private static final SSLHandshakeException OCSP_VERIFICATION_EXCEPTION = ThrowableUtil.unknownStackTrace( new SSLHandshakeException("Bad OCSP response"), OcspClientHandler.class, "verify(...)"); diff --git a/handler/src/main/java/io/netty/handler/timeout/WriteTimeoutHandler.java b/handler/src/main/java/io/netty/handler/timeout/WriteTimeoutHandler.java index 188d091e70..0cc7588578 100644 --- a/handler/src/main/java/io/netty/handler/timeout/WriteTimeoutHandler.java +++ b/handler/src/main/java/io/netty/handler/timeout/WriteTimeoutHandler.java @@ -24,7 +24,7 @@ import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInitializer; -import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelOutboundHandler; import io.netty.channel.ChannelPromise; import java.util.concurrent.ScheduledFuture; @@ -64,7 +64,7 @@ import java.util.concurrent.TimeUnit; * @see ReadTimeoutHandler * @see IdleStateHandler */ -public class WriteTimeoutHandler extends ChannelOutboundHandlerAdapter { +public class WriteTimeoutHandler implements ChannelOutboundHandler { private static final long MIN_TIMEOUT_NANOS = TimeUnit.MILLISECONDS.toNanos(1); private final long timeoutNanos; diff --git a/handler/src/test/java/io/netty/handler/flow/FlowControlHandlerTest.java b/handler/src/test/java/io/netty/handler/flow/FlowControlHandlerTest.java index 0b08df0d30..492cdd4277 100644 --- a/handler/src/test/java/io/netty/handler/flow/FlowControlHandlerTest.java +++ b/handler/src/test/java/io/netty/handler/flow/FlowControlHandlerTest.java @@ -21,10 +21,9 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelConfig; -import io.netty.channel.ChannelDuplexHandler; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelOption; import io.netty.channel.ChannelPipeline; @@ -95,7 +94,7 @@ public class FlowControlHandlerTest { bootstrap.group(GROUP) .channel(NioSocketChannel.class) .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000) - .handler(new ChannelInboundHandlerAdapter() { + .handler(new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) { fail("In this test the client is never receiving a message from the server."); @@ -120,7 +119,7 @@ public class FlowControlHandlerTest { public void testAutoReadingOn() throws Exception { final CountDownLatch latch = new CountDownLatch(3); - ChannelInboundHandlerAdapter handler = new ChannelInboundHandlerAdapter() { + ChannelInboundHandler handler = new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) { ReferenceCountUtil.release(msg); @@ -162,7 +161,7 @@ public class FlowControlHandlerTest { final Exchanger peerRef = new Exchanger<>(); final CountDownLatch latch = new CountDownLatch(3); - ChannelInboundHandlerAdapter handler = new ChannelInboundHandlerAdapter() { + ChannelInboundHandler handler = new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { peerRef.exchange(ctx.channel(), 1L, SECONDS); @@ -208,7 +207,7 @@ public class FlowControlHandlerTest { public void testFlowAutoReadOn() throws Exception { final CountDownLatch latch = new CountDownLatch(3); - ChannelInboundHandlerAdapter handler = new ChannelDuplexHandler() { + ChannelInboundHandler handler = new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) { latch.countDown(); @@ -245,7 +244,7 @@ public class FlowControlHandlerTest { final CountDownLatch setAutoReadLatch1 = new CountDownLatch(1); final CountDownLatch setAutoReadLatch2 = new CountDownLatch(1); - ChannelInboundHandlerAdapter handler = new ChannelInboundHandlerAdapter() { + ChannelInboundHandler handler = new ChannelInboundHandler() { private int msgRcvCount; private int expectedMsgCount; @Override @@ -325,7 +324,7 @@ public class FlowControlHandlerTest { final CountDownLatch msgRcvLatch2 = new CountDownLatch(2); final CountDownLatch msgRcvLatch3 = new CountDownLatch(3); - ChannelInboundHandlerAdapter handler = new ChannelDuplexHandler() { + ChannelInboundHandler handler = new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { ctx.fireChannelActive(); diff --git a/handler/src/test/java/io/netty/handler/flush/FlushConsolidationHandlerTest.java b/handler/src/test/java/io/netty/handler/flush/FlushConsolidationHandlerTest.java index bd771593c8..e290923a77 100644 --- a/handler/src/test/java/io/netty/handler/flush/FlushConsolidationHandlerTest.java +++ b/handler/src/test/java/io/netty/handler/flush/FlushConsolidationHandlerTest.java @@ -16,8 +16,8 @@ package io.netty.handler.flush; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; -import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; +import io.netty.channel.ChannelOutboundHandler; import io.netty.channel.embedded.EmbeddedChannel; import org.junit.Test; @@ -154,7 +154,7 @@ public class FlushConsolidationHandlerTest { private static EmbeddedChannel newChannel(final AtomicInteger flushCount, boolean consolidateWhenNoReadInProgress) { return new EmbeddedChannel( - new ChannelOutboundHandlerAdapter() { + new ChannelOutboundHandler() { @Override public void flush(ChannelHandlerContext ctx) throws Exception { flushCount.incrementAndGet(); @@ -162,7 +162,7 @@ public class FlushConsolidationHandlerTest { } }, new FlushConsolidationHandler(EXPLICIT_FLUSH_AFTER_FLUSHES, consolidateWhenNoReadInProgress), - new ChannelInboundHandlerAdapter() { + new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { ctx.writeAndFlush(msg); diff --git a/handler/src/test/java/io/netty/handler/ssl/ParameterizedSslHandlerTest.java b/handler/src/test/java/io/netty/handler/ssl/ParameterizedSslHandlerTest.java index fdd7e1002d..8307802174 100644 --- a/handler/src/test/java/io/netty/handler/ssl/ParameterizedSslHandlerTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/ParameterizedSslHandlerTest.java @@ -20,10 +20,9 @@ import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.ByteBuf; import io.netty.buffer.CompositeByteBuf; import io.netty.channel.Channel; -import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.EventLoopGroup; import io.netty.channel.MultithreadEventLoopGroup; @@ -35,7 +34,6 @@ import io.netty.handler.ssl.util.SelfSignedCertificate; import io.netty.handler.ssl.util.SimpleTrustManagerFactory; import io.netty.util.ReferenceCountUtil; import io.netty.util.internal.ResourcesUtil; -import io.netty.util.concurrent.Future; import io.netty.util.concurrent.FutureListener; import io.netty.util.concurrent.Promise; import io.netty.util.concurrent.PromiseNotifier; @@ -154,7 +152,7 @@ public class ParameterizedSslHandlerTest { handler.setWrapDataSize(-1); } ch.pipeline().addLast(handler); - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { private boolean sentData; private Throwable writeCause; @@ -208,7 +206,7 @@ public class ParameterizedSslHandlerTest { } else { ch.pipeline().addLast(new SslHandler(sslClientCtx.newEngine(ch.alloc()))); } - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { private int bytesSeen; @Override public void channelRead(ChannelHandlerContext ctx, Object msg) { @@ -316,7 +314,7 @@ public class ParameterizedSslHandlerTest { @Override protected void initChannel(Channel ch) throws Exception { ch.pipeline().addLast(sslServerCtx.newHandler(ch.alloc())); - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { // Just trigger a close @@ -333,7 +331,7 @@ public class ParameterizedSslHandlerTest { @Override protected void initChannel(Channel ch) throws Exception { ch.pipeline().addLast(sslClientCtx.newHandler(ch.alloc())); - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { if (cause.getCause() instanceof SSLException) { @@ -430,7 +428,7 @@ public class ParameterizedSslHandlerTest { protected void initChannel(Channel ch) throws Exception { final AtomicBoolean closeSent = new AtomicBoolean(); if (timeout) { - ch.pipeline().addFirst(new ChannelInboundHandlerAdapter() { + ch.pipeline().addFirst(new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (closeSent.get()) { @@ -438,7 +436,7 @@ public class ParameterizedSslHandlerTest { // close_notify. ReferenceCountUtil.release(msg); } else { - super.channelRead(ctx, msg); + ctx.fireChannelRead(msg); } } }); diff --git a/handler/src/test/java/io/netty/handler/ssl/RenegotiateTest.java b/handler/src/test/java/io/netty/handler/ssl/RenegotiateTest.java index 40fde94558..63606e0290 100644 --- a/handler/src/test/java/io/netty/handler/ssl/RenegotiateTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/RenegotiateTest.java @@ -19,7 +19,7 @@ import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.EventLoopGroup; import io.netty.channel.MultithreadEventLoopGroup; @@ -30,7 +30,6 @@ import io.netty.channel.local.LocalServerChannel; import io.netty.handler.ssl.util.InsecureTrustManagerFactory; import io.netty.handler.ssl.util.SelfSignedCertificate; import io.netty.util.ReferenceCountUtil; -import io.netty.util.concurrent.Future; import io.netty.util.concurrent.FutureListener; import org.junit.Test; @@ -54,7 +53,7 @@ public abstract class RenegotiateTest { @Override protected void initChannel(Channel ch) throws Exception { ch.pipeline().addLast(context.newHandler(ch.alloc())); - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { private boolean renegotiate; @Override @@ -101,7 +100,7 @@ public abstract class RenegotiateTest { @Override protected void initChannel(Channel ch) throws Exception { ch.pipeline().addLast(clientContext.newHandler(ch.alloc())); - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void userEventTriggered( ChannelHandlerContext ctx, Object evt) throws Exception { diff --git a/handler/src/test/java/io/netty/handler/ssl/SSLEngineTest.java b/handler/src/test/java/io/netty/handler/ssl/SSLEngineTest.java index ec10f667fb..a64682a843 100644 --- a/handler/src/test/java/io/netty/handler/ssl/SSLEngineTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/SSLEngineTest.java @@ -25,7 +25,7 @@ import io.netty.buffer.UnpooledByteBufAllocator; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; import io.netty.channel.MultithreadEventLoopGroup; @@ -740,7 +740,7 @@ public abstract class SSLEngineTest { } p.addLast(handler); p.addLast(new MessageDelegatorChannelHandler(serverReceiver, serverLatch)); - p.addLast(new ChannelInboundHandlerAdapter() { + p.addLast(new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt == SslHandshakeCompletionEvent.SUCCESS) { @@ -782,7 +782,7 @@ public abstract class SSLEngineTest { clientSslCtx.newHandler(ch.alloc(), delegatingExecutor); p.addLast(handler); p.addLast(new MessageDelegatorChannelHandler(clientReceiver, clientLatch)); - p.addLast(new ChannelInboundHandlerAdapter() { + p.addLast(new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt == SslHandshakeCompletionEvent.SUCCESS) { @@ -889,7 +889,7 @@ public abstract class SSLEngineTest { serverSslCtx.newHandler(ch.alloc(), delegatingExecutor); p.addLast(handler); p.addLast(new MessageDelegatorChannelHandler(serverReceiver, serverLatch)); - p.addLast(new ChannelInboundHandlerAdapter() { + p.addLast(new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt == SslHandshakeCompletionEvent.SUCCESS) { @@ -941,7 +941,7 @@ public abstract class SSLEngineTest { sslHandler.engine().setSSLParameters(parameters); p.addLast(sslHandler); p.addLast(new MessageDelegatorChannelHandler(clientReceiver, clientLatch)); - p.addLast(new ChannelInboundHandlerAdapter() { + p.addLast(new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt == SslHandshakeCompletionEvent.SUCCESS) { @@ -1061,7 +1061,7 @@ public abstract class SSLEngineTest { p.addLast(new SslHandler(engine)); p.addLast(new MessageDelegatorChannelHandler(serverReceiver, serverLatch)); - p.addLast(new ChannelInboundHandlerAdapter() { + p.addLast(new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { if (cause.getCause() instanceof SSLHandshakeException) { @@ -1104,7 +1104,7 @@ public abstract class SSLEngineTest { ChannelPipeline p = ch.pipeline(); p.addLast(handler); p.addLast(new MessageDelegatorChannelHandler(clientReceiver, clientLatch)); - p.addLast(new ChannelInboundHandlerAdapter() { + p.addLast(new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt == SslHandshakeCompletionEvent.SUCCESS) { @@ -1300,7 +1300,7 @@ public abstract class SSLEngineTest { serverSslCtx.newHandler(ch.alloc(), delegatingExecutor); p.addLast(handler); - p.addLast(new ChannelInboundHandlerAdapter() { + p.addLast(new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { if (evt instanceof SslHandshakeCompletionEvent && @@ -1361,7 +1361,7 @@ public abstract class SSLEngineTest { // the unit test can terminate relativley quicly. sslHandler.setHandshakeTimeout(1, TimeUnit.SECONDS); p.addLast(sslHandler); - p.addLast(new ChannelInboundHandlerAdapter() { + p.addLast(new ChannelInboundHandler() { private int handshakeCount; @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { @@ -1650,7 +1650,7 @@ public abstract class SSLEngineTest { p.addLast(sslHandler); p.addLast(new MessageDelegatorChannelHandler(serverReceiver, serverLatch)); - p.addLast(new ChannelInboundHandlerAdapter() { + p.addLast(new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { if (cause.getCause() instanceof SSLHandshakeException) { @@ -1680,7 +1680,7 @@ public abstract class SSLEngineTest { p.addLast(sslHandler); p.addLast(new MessageDelegatorChannelHandler(clientReceiver, clientLatch)); - p.addLast(new ChannelInboundHandlerAdapter() { + p.addLast(new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { if (cause.getCause() instanceof SSLHandshakeException) { @@ -1734,7 +1734,7 @@ public abstract class SSLEngineTest { serverSslCtx.newHandler(ch.alloc(), delegatingExecutor); ch.pipeline().addFirst(sslHandler); - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof SslHandshakeCompletionEvent) { diff --git a/handler/src/test/java/io/netty/handler/ssl/SniClientJava8TestUtil.java b/handler/src/test/java/io/netty/handler/ssl/SniClientJava8TestUtil.java index a7d85f8d02..71b5244efe 100644 --- a/handler/src/test/java/io/netty/handler/ssl/SniClientJava8TestUtil.java +++ b/handler/src/test/java/io/netty/handler/ssl/SniClientJava8TestUtil.java @@ -20,7 +20,7 @@ import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.ByteBufAllocator; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.MultithreadEventLoopGroup; import io.netty.channel.EventLoopGroup; @@ -108,7 +108,7 @@ final class SniClientJava8TestUtil { handler.engine().setSSLParameters(parameters); ch.pipeline().addFirst(handler); - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof SslHandshakeCompletionEvent) { diff --git a/handler/src/test/java/io/netty/handler/ssl/SniHandlerTest.java b/handler/src/test/java/io/netty/handler/ssl/SniHandlerTest.java index 58b84f97ce..46ebc5d8d6 100644 --- a/handler/src/test/java/io/netty/handler/ssl/SniHandlerTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/SniHandlerTest.java @@ -24,7 +24,7 @@ import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; import io.netty.channel.MultithreadEventLoopGroup; @@ -149,7 +149,7 @@ public class SniHandlerTest { final AtomicReference evtRef = new AtomicReference<>(); SniHandler handler = new SniHandler(new DomainNameMappingBuilder<>(nettyContext).build()); - EmbeddedChannel ch = new EmbeddedChannel(handler, new ChannelInboundHandlerAdapter() { + EmbeddedChannel ch = new EmbeddedChannel(handler, new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof SslHandshakeCompletionEvent) { @@ -196,7 +196,7 @@ public class SniHandlerTest { final AtomicReference evtRef = new AtomicReference<>(); SniHandler handler = new SniHandler(mapping); - EmbeddedChannel ch = new EmbeddedChannel(handler, new ChannelInboundHandlerAdapter() { + EmbeddedChannel ch = new EmbeddedChannel(handler, new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof SniCompletionEvent) { diff --git a/handler/src/test/java/io/netty/handler/ssl/SslErrorTest.java b/handler/src/test/java/io/netty/handler/ssl/SslErrorTest.java index f576e32ca3..54324787f1 100644 --- a/handler/src/test/java/io/netty/handler/ssl/SslErrorTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/SslErrorTest.java @@ -19,7 +19,7 @@ import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.EventLoopGroup; import io.netty.channel.MultithreadEventLoopGroup; @@ -174,7 +174,7 @@ public class SslErrorTest { @Override protected void initChannel(Channel ch) throws Exception { ch.pipeline().addLast(sslServerCtx.newHandler(ch.alloc())); - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { @@ -192,7 +192,7 @@ public class SslErrorTest { @Override protected void initChannel(Channel ch) throws Exception { ch.pipeline().addLast(sslClientCtx.newHandler(ch.alloc())); - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { // Unwrap as its wrapped by a DecoderException diff --git a/handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java b/handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java index e8dcba2c5b..35c526a3a0 100644 --- a/handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java @@ -27,9 +27,9 @@ import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; -import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelOutboundHandler; import io.netty.channel.ChannelPromise; import io.netty.channel.DefaultChannelId; import io.netty.channel.MultithreadEventLoopGroup; @@ -95,7 +95,7 @@ public class SslHandlerTest { SSLEngine engine = SSLContext.getDefault().createSSLEngine(); EmbeddedChannel ch = new EmbeddedChannel( - DefaultChannelId.newInstance(), false, false, new ChannelInboundHandlerAdapter() { + DefaultChannelId.newInstance(), false, false, new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { // Not forward the event to the SslHandler but just close the Channel. @@ -110,7 +110,7 @@ public class SslHandlerTest { super.handlerAdded(ctx); inActive.set(false); } - }, new ChannelInboundHandlerAdapter() { + }, new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof SslHandshakeCompletionEvent) { @@ -274,13 +274,13 @@ public class SslHandlerTest { } } - private static final class TlsReadTest extends ChannelOutboundHandlerAdapter { + private static final class TlsReadTest implements ChannelOutboundHandler { private volatile boolean readIssued; @Override public void read(ChannelHandlerContext ctx) throws Exception { readIssued = true; - super.read(ctx); + ctx.read(); } public void test(final boolean dropChannelActive) throws Exception { @@ -290,7 +290,7 @@ public class SslHandlerTest { EmbeddedChannel ch = new EmbeddedChannel(false, false, this, new SslHandler(engine), - new ChannelInboundHandlerAdapter() { + new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { if (!dropChannelActive) { @@ -375,7 +375,7 @@ public class SslHandlerTest { ch.eventLoop().execute(ch::close); }); - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { if (cause instanceof CodecException) { @@ -418,7 +418,7 @@ public class SslHandlerTest { public void testEventsFired() throws Exception { SSLEngine engine = newServerModeSSLEngine(); final BlockingQueue events = new LinkedBlockingQueue<>(); - EmbeddedChannel channel = new EmbeddedChannel(new SslHandler(engine), new ChannelInboundHandlerAdapter() { + EmbeddedChannel channel = new EmbeddedChannel(new SslHandler(engine), new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof SslCompletionEvent) { @@ -457,7 +457,7 @@ public class SslHandlerTest { @Override protected void initChannel(Channel ch) { ch.pipeline().addLast(sslServerCtx.newHandler(ch.alloc())); - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) { ByteBuf buf = ctx.alloc().buffer(10); @@ -486,7 +486,7 @@ public class SslHandlerTest { .handler(new ChannelInitializer() { @Override protected void initChannel(Channel ch) { - ch.pipeline().addFirst(new ChannelInboundHandlerAdapter() { + ch.pipeline().addFirst(new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) { ByteBuf buf = ctx.alloc().buffer(1000); @@ -691,7 +691,7 @@ public class SslHandlerTest { sc = new ServerBootstrap() .group(group) .channel(NioServerSocketChannel.class) - .childHandler(new ChannelInboundHandlerAdapter()) + .childHandler(new ChannelInboundHandler() { }) .bind(new InetSocketAddress(0)).syncUninterruptibly().channel(); cc = new Bootstrap() @@ -701,7 +701,7 @@ public class SslHandlerTest { @Override protected void initChannel(Channel ch) throws Exception { ch.pipeline().addLast(sslHandler); - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { @@ -770,7 +770,7 @@ public class SslHandlerTest { sc = new ServerBootstrap() .group(group) .channel(NioServerSocketChannel.class) - .childHandler(new ChannelInboundHandlerAdapter()) + .childHandler(new ChannelInboundHandler() { }) .bind(new InetSocketAddress(0)).syncUninterruptibly().channel(); ChannelFuture future = new Bootstrap() @@ -781,7 +781,7 @@ public class SslHandlerTest { protected void initChannel(Channel ch) throws Exception { ch.pipeline().addLast(sslHandler); if (startTls) { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { ctx.writeAndFlush(wrappedBuffer(new byte[] { 1, 2, 3, 4 })); diff --git a/handler/src/test/java/io/netty/handler/ssl/ocsp/OcspTest.java b/handler/src/test/java/io/netty/handler/ssl/ocsp/OcspTest.java index e53cba0ea4..9a8f771a8f 100644 --- a/handler/src/test/java/io/netty/handler/ssl/ocsp/OcspTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/ocsp/OcspTest.java @@ -23,7 +23,7 @@ import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; import io.netty.channel.MultithreadEventLoopGroup; @@ -164,7 +164,7 @@ public class OcspTest { */ private static void testClientAcceptingOcspStaple(SslProvider sslProvider) throws Exception { final CountDownLatch latch = new CountDownLatch(1); - ChannelInboundHandlerAdapter serverHandler = new ChannelInboundHandlerAdapter() { + ChannelInboundHandler serverHandler = new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { ctx.writeAndFlush(Unpooled.wrappedBuffer("Hello, World!".getBytes())); @@ -172,7 +172,7 @@ public class OcspTest { } }; - ChannelInboundHandlerAdapter clientHandler = new ChannelInboundHandlerAdapter() { + ChannelInboundHandler clientHandler = new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { try { @@ -212,7 +212,7 @@ public class OcspTest { final AtomicReference causeRef = new AtomicReference<>(); final CountDownLatch latch = new CountDownLatch(1); - ChannelInboundHandlerAdapter clientHandler = new ChannelInboundHandlerAdapter() { + ChannelInboundHandler clientHandler = new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { try { @@ -253,7 +253,7 @@ public class OcspTest { */ private static void testServerHasNoStaple(SslProvider sslProvider) throws Exception { final CountDownLatch latch = new CountDownLatch(1); - ChannelInboundHandlerAdapter serverHandler = new ChannelInboundHandlerAdapter() { + ChannelInboundHandler serverHandler = new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { ctx.writeAndFlush(Unpooled.wrappedBuffer("Hello, World!".getBytes())); @@ -261,7 +261,7 @@ public class OcspTest { } }; - ChannelInboundHandlerAdapter clientHandler = new ChannelInboundHandlerAdapter() { + ChannelInboundHandler clientHandler = new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { try { @@ -302,7 +302,7 @@ public class OcspTest { final AtomicReference causeRef = new AtomicReference<>(); final CountDownLatch latch = new CountDownLatch(1); - ChannelInboundHandlerAdapter clientHandler = new ChannelInboundHandlerAdapter() { + ChannelInboundHandler clientHandler = new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { try { diff --git a/handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java b/handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java index 77e16750be..f336b251cb 100644 --- a/handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java +++ b/handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java @@ -21,7 +21,7 @@ import io.netty.buffer.Unpooled; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelOutboundHandler; import io.netty.channel.ChannelPromise; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.util.CharsetUtil; @@ -273,7 +273,7 @@ public class ChunkedWriteHandlerTest { // See https://github.com/netty/netty/issues/8700. @Test public void testFailureWhenLastChunkFailed() throws IOException { - ChannelOutboundHandlerAdapter failLast = new ChannelOutboundHandlerAdapter() { + ChannelOutboundHandler failLast = new ChannelOutboundHandler() { private int passedWrites; @Override @@ -409,7 +409,7 @@ public class ChunkedWriteHandlerTest { } }; - ChannelOutboundHandlerAdapter noOpWrites = new ChannelOutboundHandlerAdapter() { + ChannelOutboundHandler noOpWrites = new ChannelOutboundHandler() { @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) { ReferenceCountUtil.release(msg); @@ -595,7 +595,7 @@ public class ChunkedWriteHandlerTest { } private static void checkFirstFailed(Object input) { - ChannelOutboundHandlerAdapter noOpWrites = new ChannelOutboundHandlerAdapter() { + ChannelOutboundHandler noOpWrites = new ChannelOutboundHandler() { @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) { ReferenceCountUtil.release(msg); @@ -612,7 +612,7 @@ public class ChunkedWriteHandlerTest { } private static void checkSkipFailed(Object input1, Object input2) { - ChannelOutboundHandlerAdapter failFirst = new ChannelOutboundHandlerAdapter() { + ChannelOutboundHandler failFirst = new ChannelOutboundHandler() { private boolean alreadyFailed; @Override diff --git a/handler/src/test/java/io/netty/handler/timeout/IdleStateHandlerTest.java b/handler/src/test/java/io/netty/handler/timeout/IdleStateHandlerTest.java index 7181b71282..aeaf79064f 100644 --- a/handler/src/test/java/io/netty/handler/timeout/IdleStateHandlerTest.java +++ b/handler/src/test/java/io/netty/handler/timeout/IdleStateHandlerTest.java @@ -25,7 +25,7 @@ import static org.junit.Assert.assertTrue; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelOutboundBuffer; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.util.ReferenceCountUtil; @@ -72,7 +72,7 @@ public class IdleStateHandlerTest { assertTrue("The number of expected events must be >= 1", expected.length >= 1); final List events = new ArrayList<>(); - ChannelInboundHandlerAdapter handler = new ChannelInboundHandlerAdapter() { + ChannelInboundHandler handler = new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { events.add(evt); @@ -143,7 +143,7 @@ public class IdleStateHandlerTest { Action action, Object expected) throws Exception { final List events = new ArrayList<>(); - ChannelInboundHandlerAdapter handler = new ChannelInboundHandlerAdapter() { + ChannelInboundHandler handler = new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { events.add(evt); @@ -203,7 +203,7 @@ public class IdleStateHandlerTest { true, 0L, writerIdleTime, allIdleTime, TimeUnit.SECONDS); final List events = new ArrayList<>(); - ChannelInboundHandlerAdapter handler = new ChannelInboundHandlerAdapter() { + ChannelInboundHandler handler = new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { events.add(evt); diff --git a/microbench/src/main/java/io/netty/handler/codec/http2/Http2FrameWriterDataBenchmark.java b/microbench/src/main/java/io/netty/handler/codec/http2/Http2FrameWriterDataBenchmark.java index 9b29f7c9e7..8889809473 100644 --- a/microbench/src/main/java/io/netty/handler/codec/http2/Http2FrameWriterDataBenchmark.java +++ b/microbench/src/main/java/io/netty/handler/codec/http2/Http2FrameWriterDataBenchmark.java @@ -20,7 +20,7 @@ import io.netty.buffer.Unpooled; import io.netty.buffer.UnpooledByteBufAllocator; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelPromise; import io.netty.microbench.channel.EmbeddedChannelWriteReleaseHandlerContext; import io.netty.microbench.util.AbstractMicrobenchmark; @@ -79,7 +79,7 @@ public class Http2FrameWriterDataBenchmark extends AbstractMicrobenchmark { payload.writeZero(payloadSize); ctx = new EmbeddedChannelWriteReleaseHandlerContext( pooled ? PooledByteBufAllocator.DEFAULT : UnpooledByteBufAllocator.DEFAULT, - new ChannelInboundHandlerAdapter()) { + new ChannelInboundHandler() { }) { @Override protected void handleException(Throwable t) { handleUnexpectedException(t); diff --git a/microbench/src/main/java/io/netty/microbench/channel/DefaultChannelPipelineBenchmark.java b/microbench/src/main/java/io/netty/microbench/channel/DefaultChannelPipelineBenchmark.java index 2747ccfd98..39b35127f1 100644 --- a/microbench/src/main/java/io/netty/microbench/channel/DefaultChannelPipelineBenchmark.java +++ b/microbench/src/main/java/io/netty/microbench/channel/DefaultChannelPipelineBenchmark.java @@ -15,9 +15,9 @@ */ package io.netty.microbench.channel; +import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandler; -import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelPipeline; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.microbench.util.AbstractMicrobenchmark; @@ -37,23 +37,15 @@ import org.openjdk.jmh.infra.Blackhole; @State(Scope.Benchmark) public class DefaultChannelPipelineBenchmark extends AbstractMicrobenchmark { - private static final ChannelInboundHandler NOOP_HANDLER = new ChannelInboundHandlerAdapter() { - @Override - public boolean isSharable() { - return true; - } - }; + @ChannelHandler.Sharable + private static final ChannelInboundHandler NOOP_HANDLER = new ChannelInboundHandler() { }; - private static final ChannelInboundHandler CONSUMING_HANDLER = new ChannelInboundHandlerAdapter() { + @ChannelHandler.Sharable + private static final ChannelInboundHandler CONSUMING_HANDLER = new ChannelInboundHandler() { @Override public void channelReadComplete(ChannelHandlerContext ctx) { // NOOP } - - @Override - public boolean isSharable() { - return true; - } }; @Param({ "4" }) diff --git a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java index 6be02ce4e8..da4cf59f7f 100644 --- a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java +++ b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java @@ -24,7 +24,7 @@ import io.netty.channel.ChannelFactory; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelOption; import io.netty.channel.ChannelPromise; @@ -1111,7 +1111,7 @@ public class DnsNameResolver extends InetNameResolver { return dnsServerAddressStreamProvider.nameServerAddressStream(hostname); } - private final class DnsResponseHandler extends ChannelInboundHandlerAdapter { + private final class DnsResponseHandler implements ChannelInboundHandler { private final Promise channelActivePromise; @@ -1143,7 +1143,7 @@ public class DnsNameResolver extends InetNameResolver { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { - super.channelActive(ctx); + ctx.fireChannelActive(); channelActivePromise.setSuccess(ctx.channel()); } diff --git a/testsuite-autobahn/src/main/java/io/netty/testsuite/autobahn/AutobahnServerHandler.java b/testsuite-autobahn/src/main/java/io/netty/testsuite/autobahn/AutobahnServerHandler.java index 933c135887..0efcf96b84 100644 --- a/testsuite-autobahn/src/main/java/io/netty/testsuite/autobahn/AutobahnServerHandler.java +++ b/testsuite-autobahn/src/main/java/io/netty/testsuite/autobahn/AutobahnServerHandler.java @@ -20,7 +20,7 @@ import io.netty.buffer.Unpooled; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.HttpHeaderNames; @@ -48,7 +48,7 @@ import static io.netty.handler.codec.http.HttpVersion.*; /** * Handles handshakes and messages */ -public class AutobahnServerHandler extends ChannelInboundHandlerAdapter { +public class AutobahnServerHandler implements ChannelInboundHandler { private static final Logger logger = Logger.getLogger(AutobahnServerHandler.class.getName()); private WebSocketServerHandshaker handshaker; diff --git a/testsuite-http2/src/main/java/io/netty/testsuite/http2/Http2ServerInitializer.java b/testsuite-http2/src/main/java/io/netty/testsuite/http2/Http2ServerInitializer.java index 1393677a41..9955d03229 100644 --- a/testsuite-http2/src/main/java/io/netty/testsuite/http2/Http2ServerInitializer.java +++ b/testsuite-http2/src/main/java/io/netty/testsuite/http2/Http2ServerInitializer.java @@ -19,7 +19,7 @@ package io.netty.testsuite.http2; import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; import io.netty.channel.SimpleChannelInboundHandler; @@ -28,7 +28,6 @@ import io.netty.handler.codec.http.HttpMessage; import io.netty.handler.codec.http.HttpObjectAggregator; import io.netty.handler.codec.http.HttpServerCodec; import io.netty.handler.codec.http.HttpServerUpgradeHandler; -import io.netty.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodec; import io.netty.handler.codec.http.HttpServerUpgradeHandler.UpgradeCodecFactory; import io.netty.handler.codec.http2.CleartextHttp2ServerUpgradeHandler; import io.netty.handler.codec.http2.Http2CodecUtil; @@ -97,7 +96,7 @@ public class Http2ServerInitializer extends ChannelInitializer { /** * Class that logs any User Events triggered on this channel. */ - private static class UserEventLogger extends ChannelInboundHandlerAdapter { + private static class UserEventLogger implements ChannelInboundHandler { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { System.out.println("User Event Triggered: " + evt); diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/CompositeBufferGatheringWriteTest.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/CompositeBufferGatheringWriteTest.java index d3d4644ced..ace672d2de 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/CompositeBufferGatheringWriteTest.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/CompositeBufferGatheringWriteTest.java @@ -24,7 +24,7 @@ import io.netty.channel.Channel; import io.netty.channel.ChannelConfig; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelOption; import io.netty.util.ReferenceCountUtil; @@ -54,7 +54,7 @@ public class CompositeBufferGatheringWriteTest extends AbstractSocketTest { sb.childHandler(new ChannelInitializer() { @Override protected void initChannel(Channel ch) throws Exception { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { ctx.writeAndFlush(newCompositeBuffer(ctx.alloc())) @@ -66,7 +66,7 @@ public class CompositeBufferGatheringWriteTest extends AbstractSocketTest { cb.handler(new ChannelInitializer() { @Override protected void initChannel(Channel ch) throws Exception { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { private ByteBuf aggregator; @Override public void handlerAdded(ChannelHandlerContext ctx) { @@ -164,7 +164,7 @@ public class CompositeBufferGatheringWriteTest extends AbstractSocketTest { .childHandler(new ChannelInitializer() { @Override protected void initChannel(Channel ch) throws Exception { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { compositeBufferPartialWriteDoesNotCorruptDataInitServerConfig(ctx.channel().config(), @@ -208,7 +208,7 @@ public class CompositeBufferGatheringWriteTest extends AbstractSocketTest { cb.handler(new ChannelInitializer() { @Override protected void initChannel(Channel ch) throws Exception { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { private ByteBuf aggregator; @Override public void handlerAdded(ChannelHandlerContext ctx) { diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/DatagramConnectNotExistsTest.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/DatagramConnectNotExistsTest.java index 2eb8753b91..c236240a06 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/DatagramConnectNotExistsTest.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/DatagramConnectNotExistsTest.java @@ -20,7 +20,7 @@ import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.util.CharsetUtil; import io.netty.util.NetUtil; @@ -46,7 +46,7 @@ public class DatagramConnectNotExistsTest extends AbstractClientSocketTest { public void testConnectNotExists(Bootstrap cb) throws Throwable { final Promise promise = ImmediateEventExecutor.INSTANCE.newPromise(); - cb.handler(new ChannelInboundHandlerAdapter() { + cb.handler(new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { promise.trySuccess(cause); diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/ServerSocketSuspendTest.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/ServerSocketSuspendTest.java index 6adc603918..df827a83f3 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/ServerSocketSuspendTest.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/ServerSocketSuspendTest.java @@ -19,7 +19,7 @@ import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.Channel; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelOption; import io.netty.util.internal.SocketUtils; import org.junit.Ignore; @@ -94,7 +94,7 @@ public class ServerSocketSuspendTest extends AbstractServerSocketTest { } @ChannelHandler.Sharable - private static final class AcceptedChannelCounter extends ChannelInboundHandlerAdapter { + private static final class AcceptedChannelCounter implements ChannelInboundHandler { final CountDownLatch latch; diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketAutoReadTest.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketAutoReadTest.java index d511fcc086..96ba792630 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketAutoReadTest.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketAutoReadTest.java @@ -23,7 +23,7 @@ import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelConfig; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelOption; import io.netty.channel.RecvByteBufAllocator; @@ -116,7 +116,7 @@ public class SocketAutoReadTest extends AbstractSocketTest { } } - private static final class AutoReadHandler extends ChannelInboundHandlerAdapter { + private static final class AutoReadHandler implements ChannelInboundHandler { private final AtomicInteger count = new AtomicInteger(); private final CountDownLatch latch = new CountDownLatch(1); private final CountDownLatch latch2; diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketChannelNotYetConnectedTest.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketChannelNotYetConnectedTest.java index eee70e63bd..2567ca2fd1 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketChannelNotYetConnectedTest.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketChannelNotYetConnectedTest.java @@ -16,7 +16,7 @@ package io.netty.testsuite.transport.socket; import io.netty.bootstrap.Bootstrap; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.socket.SocketChannel; import org.junit.Test; @@ -32,7 +32,7 @@ public class SocketChannelNotYetConnectedTest extends AbstractClientSocketTest { } public void testShutdownNotYetConnected(Bootstrap cb) throws Throwable { - SocketChannel ch = (SocketChannel) cb.handler(new ChannelInboundHandlerAdapter()) + SocketChannel ch = (SocketChannel) cb.handler(new ChannelInboundHandler() { }) .bind(newSocketAddress()).syncUninterruptibly().channel(); try { try { diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketCloseForciblyTest.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketCloseForciblyTest.java index 3dd38214c2..4ccc46324c 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketCloseForciblyTest.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketCloseForciblyTest.java @@ -19,7 +19,7 @@ import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.socket.SocketChannel; import org.junit.Test; @@ -31,7 +31,7 @@ public class SocketCloseForciblyTest extends AbstractSocketTest { } public void testCloseForcibly(ServerBootstrap sb, Bootstrap cb) throws Throwable { - sb.handler(new ChannelInboundHandlerAdapter() { + sb.handler(new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { final SocketChannel childChannel = (SocketChannel) msg; @@ -41,9 +41,9 @@ public class SocketCloseForciblyTest extends AbstractSocketTest { childChannel.unsafe().closeForcibly(); }); } - }).childHandler(new ChannelInboundHandlerAdapter()); + }).childHandler(new ChannelInboundHandler() { }); - cb.handler(new ChannelInboundHandlerAdapter()); + cb.handler(new ChannelInboundHandler() { }); Channel sc = sb.bind().sync().channel(); diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketConditionalWritabilityTest.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketConditionalWritabilityTest.java index d5265a1a4c..1b8bc8d1ec 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketConditionalWritabilityTest.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketConditionalWritabilityTest.java @@ -21,7 +21,7 @@ import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; import io.netty.channel.ChannelDuplexHandler; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelOption; import io.netty.channel.WriteBufferWaterMark; @@ -90,7 +90,7 @@ public class SocketConditionalWritabilityTest extends AbstractSocketTest { cb.handler(new ChannelInitializer() { @Override protected void initChannel(Channel ch) { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { private int totalRead; @Override public void channelActive(ChannelHandlerContext ctx) { diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketConnectTest.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketConnectTest.java index 9d39111381..9ff708dd50 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketConnectTest.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketConnectTest.java @@ -20,7 +20,7 @@ import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.util.concurrent.ImmediateEventExecutor; import io.netty.util.concurrent.Promise; import org.junit.Test; @@ -43,14 +43,14 @@ public class SocketConnectTest extends AbstractSocketTest { Channel clientChannel = null; try { final Promise localAddressPromise = ImmediateEventExecutor.INSTANCE.newPromise(); - serverChannel = sb.childHandler(new ChannelInboundHandlerAdapter() { + serverChannel = sb.childHandler(new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { localAddressPromise.setSuccess((InetSocketAddress) ctx.channel().localAddress()); } }).bind().syncUninterruptibly().channel(); - clientChannel = cb.handler(new ChannelInboundHandlerAdapter()).register().syncUninterruptibly().channel(); + clientChannel = cb.handler(new ChannelInboundHandler() { }).register().syncUninterruptibly().channel(); assertNull(clientChannel.localAddress()); assertNull(clientChannel.remoteAddress()); @@ -81,10 +81,10 @@ public class SocketConnectTest extends AbstractSocketTest { Channel sc = null; Channel cc = null; try { - sb.childHandler(new ChannelInboundHandlerAdapter()); + sb.childHandler(new ChannelInboundHandler() { }); sc = sb.bind().syncUninterruptibly().channel(); - cb.handler(new ChannelInboundHandlerAdapter() { + cb.handler(new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { events.add(0); diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketConnectionAttemptTest.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketConnectionAttemptTest.java index deecd521bc..de6ff6ad2a 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketConnectionAttemptTest.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketConnectionAttemptTest.java @@ -19,7 +19,7 @@ import io.netty.bootstrap.Bootstrap; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelOption; import io.netty.util.internal.SocketUtils; import io.netty.util.NetUtil; @@ -78,7 +78,7 @@ public class SocketConnectionAttemptTest extends AbstractClientSocketTest { private static void testConnectRefused0(Bootstrap cb, boolean halfClosure) throws Throwable { final Promise errorPromise = GlobalEventExecutor.INSTANCE.newPromise(); - ChannelHandler handler = new ChannelInboundHandlerAdapter() { + ChannelHandler handler = new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { errorPromise.setFailure(new AssertionError("should have never been called")); @@ -142,7 +142,7 @@ public class SocketConnectionAttemptTest extends AbstractClientSocketTest { } } - private static class TestHandler extends ChannelInboundHandlerAdapter { + private static class TestHandler implements ChannelInboundHandler { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { InternalLoggerFactory.getInstance( diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketDataReadInitialStateTest.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketDataReadInitialStateTest.java index 7beefed778..7eccb5e8a0 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketDataReadInitialStateTest.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketDataReadInitialStateTest.java @@ -20,7 +20,7 @@ import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.SimpleChannelInboundHandler; import org.junit.Test; @@ -55,7 +55,7 @@ public class SocketDataReadInitialStateTest extends AbstractSocketTest { sb.handler(new ChannelInitializer() { @Override protected void initChannel(Channel ch) { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) { acceptorReadLatch.countDown(); diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketEchoTest.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketEchoTest.java index 1781723d86..6e0bee7a55 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketEchoTest.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketEchoTest.java @@ -21,7 +21,7 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelOption; import io.netty.channel.SimpleChannelInboundHandler; import org.junit.Test; @@ -85,7 +85,7 @@ public class SocketEchoTest extends AbstractSocketTest { final EchoHandler ch = new EchoHandler(autoRead); sb.childHandler(sh); - sb.handler(new ChannelInboundHandlerAdapter() { + sb.handler(new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { cause.printStackTrace(); diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketExceptionHandlingTest.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketExceptionHandlingTest.java index 0b73126f78..ee2df69bee 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketExceptionHandlingTest.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketExceptionHandlingTest.java @@ -20,7 +20,7 @@ import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelOption; import io.netty.channel.ChannelPipeline; @@ -83,7 +83,7 @@ public class SocketExceptionHandlingTest extends AbstractSocketTest { } } - private static class BuggyChannelHandler extends ChannelInboundHandlerAdapter { + private static class BuggyChannelHandler implements ChannelInboundHandler { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { ReferenceCountUtil.release(msg); @@ -91,7 +91,7 @@ public class SocketExceptionHandlingTest extends AbstractSocketTest { } } - private static class ExceptionHandler extends ChannelInboundHandlerAdapter { + private static class ExceptionHandler implements ChannelInboundHandler { final AtomicLong count = new AtomicLong(); /** * We expect to get 1 call to {@link #exceptionCaught(ChannelHandlerContext, Throwable)}. diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketFileRegionTest.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketFileRegionTest.java index 70ee95886e..48a103609d 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketFileRegionTest.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketFileRegionTest.java @@ -22,7 +22,6 @@ import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandler; -import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelOption; import io.netty.channel.DefaultFileRegion; import io.netty.channel.FileRegion; @@ -114,7 +113,7 @@ public class SocketFileRegionTest extends AbstractSocketTest { // Just drop the message. } }); - cb.handler(new ChannelInboundHandlerAdapter()); + cb.handler(new ChannelInboundHandler() { }); Channel sc = sb.bind().sync().channel(); Channel cc = cb.connect(sc.localAddress()).sync().channel(); diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketHalfClosedTest.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketHalfClosedTest.java index fbbbe53819..878a1ce6e3 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketHalfClosedTest.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketHalfClosedTest.java @@ -21,10 +21,9 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import io.netty.channel.Channel; import io.netty.channel.ChannelConfig; -import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelOption; import io.netty.channel.RecvByteBufAllocator; @@ -62,7 +61,7 @@ public class SocketHalfClosedTest extends AbstractSocketTest { sb.childHandler(new ChannelInitializer() { @Override protected void initChannel(Channel ch) { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) { ((DuplexChannel) ctx).shutdownOutput(); @@ -82,7 +81,7 @@ public class SocketHalfClosedTest extends AbstractSocketTest { cb.handler(new ChannelInitializer() { @Override protected void initChannel(Channel ch) { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void userEventTriggered(final ChannelHandlerContext ctx, Object evt) { @@ -142,7 +141,7 @@ public class SocketHalfClosedTest extends AbstractSocketTest { sb.childHandler(new ChannelInitializer() { @Override protected void initChannel(Channel ch) throws Exception { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { ByteBuf buf = ctx.alloc().buffer(totalServerBytesWritten); @@ -163,7 +162,7 @@ public class SocketHalfClosedTest extends AbstractSocketTest { cb.handler(new ChannelInitializer() { @Override protected void initChannel(Channel ch) throws Exception { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { private int bytesRead; @Override @@ -441,7 +440,7 @@ public class SocketHalfClosedTest extends AbstractSocketTest { sb.childHandler(new ChannelInitializer() { @Override protected void initChannel(Channel ch) throws Exception { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { ByteBuf buf = ctx.alloc().buffer(totalServerBytesWritten); @@ -461,7 +460,7 @@ public class SocketHalfClosedTest extends AbstractSocketTest { cb.handler(new ChannelInitializer() { @Override protected void initChannel(Channel ch) throws Exception { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { private int bytesRead; @Override diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketMultipleConnectTest.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketMultipleConnectTest.java index 25ccab0529..e08d8ac5e1 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketMultipleConnectTest.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketMultipleConnectTest.java @@ -19,7 +19,7 @@ import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.util.NetUtil; import org.junit.Test; @@ -41,10 +41,10 @@ public class SocketMultipleConnectTest extends AbstractSocketTest { Channel sc = null; Channel cc = null; try { - sb.childHandler(new ChannelInboundHandlerAdapter()); + sb.childHandler(new ChannelInboundHandler() { }); sc = sb.bind(NetUtil.LOCALHOST, 0).syncUninterruptibly().channel(); - cb.handler(new ChannelInboundHandlerAdapter()); + cb.handler(new ChannelInboundHandler() { }); cc = cb.register().syncUninterruptibly().channel(); cc.connect(sc.localAddress()).syncUninterruptibly(); ChannelFuture connectFuture2 = cc.connect(sc.localAddress()).await(); diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketObjectEchoTest.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketObjectEchoTest.java index 9d79dfe248..0536b6a8a3 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketObjectEchoTest.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketObjectEchoTest.java @@ -19,7 +19,7 @@ import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelOption; import io.netty.handler.codec.serialization.ClassResolvers; @@ -149,7 +149,7 @@ public class SocketObjectEchoTest extends AbstractSocketTest { } } - private static class EchoHandler extends ChannelInboundHandlerAdapter { + private static class EchoHandler implements ChannelInboundHandler { private final boolean autoRead; volatile Channel channel; final AtomicReference exception = new AtomicReference<>(); diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketReadPendingTest.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketReadPendingTest.java index 594bb82d3d..08a45768d0 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketReadPendingTest.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketReadPendingTest.java @@ -23,7 +23,7 @@ import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelConfig; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelOption; import io.netty.channel.RecvByteBufAllocator; @@ -101,7 +101,7 @@ public class SocketReadPendingTest extends AbstractSocketTest { } } - private static final class ReadPendingReadHandler extends ChannelInboundHandlerAdapter { + private static final class ReadPendingReadHandler implements ChannelInboundHandler { private final AtomicInteger count = new AtomicInteger(); private final CountDownLatch latch = new CountDownLatch(1); private final CountDownLatch latch2 = new CountDownLatch(2); diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketRstTest.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketRstTest.java index 11d52a8bac..ff97ea58cd 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketRstTest.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketRstTest.java @@ -19,7 +19,7 @@ import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelOption; import org.junit.Test; @@ -62,7 +62,7 @@ public class SocketRstTest extends AbstractSocketTest { cb.handler(new ChannelInitializer() { @Override protected void initChannel(Channel ch) throws Exception { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { throwableRef.compareAndSet(null, cause); @@ -115,7 +115,7 @@ public class SocketRstTest extends AbstractSocketTest { cb.handler(new ChannelInitializer() { @Override protected void initChannel(Channel ch) throws Exception { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { throwableRef.compareAndSet(null, cause); diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketShutdownOutputBySelfTest.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketShutdownOutputBySelfTest.java index 3fc6dbde78..a9ea18ee94 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketShutdownOutputBySelfTest.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketShutdownOutputBySelfTest.java @@ -20,7 +20,7 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelOption; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.channel.WriteBufferWaterMark; @@ -216,7 +216,7 @@ public class SocketShutdownOutputBySelfTest extends AbstractClientSocketTest { ChannelFuture cf = null; try { ss.bind(newSocketAddress()); - cf = cb.option(ChannelOption.SO_LINGER, 1).handler(new ChannelInboundHandlerAdapter()) + cf = cb.option(ChannelOption.SO_LINGER, 1).handler(new ChannelInboundHandler() { }) .connect(ss.getLocalSocketAddress()).sync(); s = ss.accept(); diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/WriteBeforeRegisteredTest.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/WriteBeforeRegisteredTest.java index cfdd961010..d9e661bf3d 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/WriteBeforeRegisteredTest.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/WriteBeforeRegisteredTest.java @@ -18,7 +18,7 @@ package io.netty.testsuite.transport.socket; import io.netty.bootstrap.Bootstrap; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.socket.SocketChannel; import org.junit.Test; @@ -42,7 +42,7 @@ public class WriteBeforeRegisteredTest extends AbstractClientSocketTest { } } - private static class TestHandler extends ChannelInboundHandlerAdapter { + private static class TestHandler implements ChannelInboundHandler { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { cause.printStackTrace(); diff --git a/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollDomainSocketFdTest.java b/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollDomainSocketFdTest.java index b7d32f0ee5..e318eed04a 100644 --- a/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollDomainSocketFdTest.java +++ b/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollDomainSocketFdTest.java @@ -18,10 +18,9 @@ package io.netty.channel.epoll; import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.Channel; -import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.unix.DomainSocketReadMode; import io.netty.channel.unix.FileDescriptor; import io.netty.testsuite.transport.TestsuitePermutation; @@ -53,7 +52,7 @@ public class EpollDomainSocketFdTest extends AbstractSocketTest { public void testSendRecvFd(ServerBootstrap sb, Bootstrap cb) throws Throwable { final BlockingQueue queue = new LinkedBlockingQueue<>(1); - sb.childHandler(new ChannelInboundHandlerAdapter() { + sb.childHandler(new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { // Create new channel and obtain a file descriptor from it. @@ -67,7 +66,7 @@ public class EpollDomainSocketFdTest extends AbstractSocketTest { }); } }); - cb.handler(new ChannelInboundHandlerAdapter() { + cb.handler(new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { FileDescriptor fd = (FileDescriptor) msg; diff --git a/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollReuseAddrTest.java b/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollReuseAddrTest.java index febd356918..8f20a3b304 100644 --- a/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollReuseAddrTest.java +++ b/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollReuseAddrTest.java @@ -22,7 +22,7 @@ import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerAdapter; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.util.NetUtil; import io.netty.util.ReferenceCountUtil; import io.netty.util.ResourceLeakDetector; @@ -200,7 +200,7 @@ public class EpollReuseAddrTest { } @ChannelHandler.Sharable - private static class ServerSocketTestHandler extends ChannelInboundHandlerAdapter { + private static class ServerSocketTestHandler implements ChannelInboundHandler { private final AtomicBoolean accepted; ServerSocketTestHandler(AtomicBoolean accepted) { @@ -215,7 +215,7 @@ public class EpollReuseAddrTest { } @ChannelHandler.Sharable - private static class DatagramSocketTestHandler extends ChannelInboundHandlerAdapter { + private static class DatagramSocketTestHandler implements ChannelInboundHandler { private final AtomicBoolean received; DatagramSocketTestHandler(AtomicBoolean received) { diff --git a/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollServerSocketChannelConfigTest.java b/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollServerSocketChannelConfigTest.java index 71e0bfb448..5465061581 100644 --- a/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollServerSocketChannelConfigTest.java +++ b/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollServerSocketChannelConfigTest.java @@ -16,7 +16,7 @@ package io.netty.channel.epoll; import io.netty.bootstrap.ServerBootstrap; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; import io.netty.channel.MultithreadEventLoopGroup; @@ -40,7 +40,7 @@ public class EpollServerSocketChannelConfigTest { ServerBootstrap bootstrap = new ServerBootstrap(); ch = (EpollServerSocketChannel) bootstrap.group(group) .channel(EpollServerSocketChannel.class) - .childHandler(new ChannelInboundHandlerAdapter()) + .childHandler(new ChannelInboundHandler() { }) .bind(new InetSocketAddress(0)).syncUninterruptibly().channel(); } diff --git a/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollSocketChannelConfigTest.java b/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollSocketChannelConfigTest.java index 5a1b999607..532c075475 100644 --- a/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollSocketChannelConfigTest.java +++ b/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollSocketChannelConfigTest.java @@ -19,7 +19,7 @@ import static org.junit.Assert.*; import static org.junit.Assume.*; import io.netty.bootstrap.Bootstrap; import io.netty.channel.ChannelException; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; @@ -57,7 +57,7 @@ public class EpollSocketChannelConfigTest { Bootstrap bootstrap = new Bootstrap(); ch = (EpollSocketChannel) bootstrap.group(group) .channel(EpollSocketChannel.class) - .handler(new ChannelInboundHandlerAdapter()) + .handler(new ChannelInboundHandler() { }) .bind(new InetSocketAddress(0)).syncUninterruptibly().channel(); } diff --git a/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollSocketChannelTest.java b/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollSocketChannelTest.java index 31f0b00f86..4ebc009cbf 100644 --- a/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollSocketChannelTest.java +++ b/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollSocketChannelTest.java @@ -16,7 +16,7 @@ package io.netty.channel.epoll; import io.netty.bootstrap.Bootstrap; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; import io.netty.channel.MultithreadEventLoopGroup; @@ -35,7 +35,7 @@ public class EpollSocketChannelTest { Bootstrap bootstrap = new Bootstrap(); EpollSocketChannel ch = (EpollSocketChannel) bootstrap.group(group) .channel(EpollSocketChannel.class) - .handler(new ChannelInboundHandlerAdapter()) + .handler(new ChannelInboundHandler() { }) .bind(new InetSocketAddress(0)).syncUninterruptibly().channel(); EpollTcpInfo info = ch.tcpInfo(); assertTcpInfo0(info); @@ -53,7 +53,7 @@ public class EpollSocketChannelTest { Bootstrap bootstrap = new Bootstrap(); EpollSocketChannel ch = (EpollSocketChannel) bootstrap.group(group) .channel(EpollSocketChannel.class) - .handler(new ChannelInboundHandlerAdapter()) + .handler(new ChannelInboundHandler() { }) .bind(new InetSocketAddress(0)).syncUninterruptibly().channel(); EpollTcpInfo info = new EpollTcpInfo(); ch.tcpInfo(info); @@ -111,7 +111,7 @@ public class EpollSocketChannelTest { EpollSocketChannel ch = (EpollSocketChannel) bootstrap.group(group) .channel(EpollSocketChannel.class) .option(ChannelOption.SO_LINGER, 10) - .handler(new ChannelInboundHandlerAdapter()) + .handler(new ChannelInboundHandler() { }) .bind(new InetSocketAddress(0)).syncUninterruptibly().channel(); ch.close().syncUninterruptibly(); } finally { diff --git a/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollSocketTcpMd5Test.java b/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollSocketTcpMd5Test.java index 776be3bbd6..d3d8e3a184 100644 --- a/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollSocketTcpMd5Test.java +++ b/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollSocketTcpMd5Test.java @@ -17,7 +17,7 @@ package io.netty.channel.epoll; import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelOption; import io.netty.channel.ConnectTimeoutException; import io.netty.channel.EventLoopGroup; @@ -55,7 +55,7 @@ public class EpollSocketTcpMd5Test { ServerBootstrap bootstrap = new ServerBootstrap(); server = (EpollServerSocketChannel) bootstrap.group(GROUP) .channel(EpollServerSocketChannel.class) - .childHandler(new ChannelInboundHandlerAdapter()) + .childHandler(new ChannelInboundHandler() { }) .bind(new InetSocketAddress(NetUtil.LOCALHOST4, 0)).syncUninterruptibly().channel(); } @@ -76,7 +76,7 @@ public class EpollSocketTcpMd5Test { ServerBootstrap bootstrap = new ServerBootstrap(); EpollServerSocketChannel ch = (EpollServerSocketChannel) bootstrap.group(GROUP) .channel(EpollServerSocketChannel.class) - .childHandler(new ChannelInboundHandlerAdapter()) + .childHandler(new ChannelInboundHandler() { }) .bind(new InetSocketAddress(0)).syncUninterruptibly().channel(); ch.config().setOption(EpollChannelOption.TCP_MD5SIG, @@ -93,7 +93,7 @@ public class EpollSocketTcpMd5Test { EpollSocketChannel client = (EpollSocketChannel) new Bootstrap().group(GROUP) .channel(EpollSocketChannel.class) - .handler(new ChannelInboundHandlerAdapter()) + .handler(new ChannelInboundHandler() { }) .option(EpollChannelOption.TCP_MD5SIG, Collections.singletonMap(NetUtil.LOCALHOST4, BAD_KEY)) .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000) @@ -108,7 +108,7 @@ public class EpollSocketTcpMd5Test { EpollSocketChannel client = (EpollSocketChannel) new Bootstrap().group(GROUP) .channel(EpollSocketChannel.class) - .handler(new ChannelInboundHandlerAdapter()) + .handler(new ChannelInboundHandler() { }) .option(EpollChannelOption.TCP_MD5SIG, Collections.singletonMap(NetUtil.LOCALHOST4, SERVER_KEY)) .connect(server.localAddress()).syncUninterruptibly().channel(); diff --git a/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollSpliceTest.java b/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollSpliceTest.java index 6a4ad43c9e..869ef69eaa 100644 --- a/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollSpliceTest.java +++ b/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollSpliceTest.java @@ -23,7 +23,7 @@ import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.EventLoopGroup; import io.netty.channel.MultithreadEventLoopGroup; import io.netty.channel.SimpleChannelInboundHandler; @@ -64,7 +64,7 @@ public class EpollSpliceTest { ServerBootstrap bs2 = new ServerBootstrap(); bs2.channel(EpollServerSocketChannel.class); bs2.childOption(EpollChannelOption.EPOLL_MODE, EpollMode.LEVEL_TRIGGERED); - bs2.group(group).childHandler(new ChannelInboundHandlerAdapter() { + bs2.group(group).childHandler(new ChannelInboundHandler() { @Override public void channelActive(final ChannelHandlerContext ctx) throws Exception { ctx.channel().config().setAutoRead(false); @@ -72,7 +72,7 @@ public class EpollSpliceTest { bs.option(EpollChannelOption.EPOLL_MODE, EpollMode.LEVEL_TRIGGERED); bs.channel(EpollSocketChannel.class); - bs.group(ctx.channel().eventLoop()).handler(new ChannelInboundHandlerAdapter() { + bs.group(ctx.channel().eventLoop()).handler(new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext context) throws Exception { final EpollSocketChannel ch = (EpollSocketChannel) ctx.channel(); @@ -195,7 +195,7 @@ public class EpollSpliceTest { Bootstrap cb = new Bootstrap(); cb.group(group); cb.channel(EpollSocketChannel.class); - cb.handler(new ChannelInboundHandlerAdapter()); + cb.handler(new ChannelInboundHandler() { }); Channel cc = cb.connect(sc.localAddress()).syncUninterruptibly().channel(); for (int i = 0; i < data.length;) { @@ -278,7 +278,7 @@ public class EpollSpliceTest { } } - private static class SpliceHandler extends ChannelInboundHandlerAdapter { + private static class SpliceHandler implements ChannelInboundHandler { private final File file; volatile Channel channel; diff --git a/transport-native-kqueue/src/test/java/io/netty/channel/kqueue/KQueueChannelConfigTest.java b/transport-native-kqueue/src/test/java/io/netty/channel/kqueue/KQueueChannelConfigTest.java index 7f7116fa47..932ef29101 100644 --- a/transport-native-kqueue/src/test/java/io/netty/channel/kqueue/KQueueChannelConfigTest.java +++ b/transport-native-kqueue/src/test/java/io/netty/channel/kqueue/KQueueChannelConfigTest.java @@ -17,7 +17,7 @@ package io.netty.channel.kqueue; import io.netty.bootstrap.Bootstrap; import io.netty.channel.ChannelException; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; import io.netty.channel.MultithreadEventLoopGroup; @@ -80,7 +80,7 @@ public class KQueueChannelConfigTest { KQueueSocketChannel ch = (KQueueSocketChannel) bootstrap.group(group) .channel(KQueueSocketChannel.class) .option(ChannelOption.SO_LINGER, 10) - .handler(new ChannelInboundHandlerAdapter()) + .handler(new ChannelInboundHandler() { }) .bind(new InetSocketAddress(0)).syncUninterruptibly().channel(); ch.close().syncUninterruptibly(); } finally { diff --git a/transport-native-kqueue/src/test/java/io/netty/channel/kqueue/KQueueDomainSocketFdTest.java b/transport-native-kqueue/src/test/java/io/netty/channel/kqueue/KQueueDomainSocketFdTest.java index e2efeabf14..e000631504 100644 --- a/transport-native-kqueue/src/test/java/io/netty/channel/kqueue/KQueueDomainSocketFdTest.java +++ b/transport-native-kqueue/src/test/java/io/netty/channel/kqueue/KQueueDomainSocketFdTest.java @@ -18,10 +18,9 @@ package io.netty.channel.kqueue; import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.Channel; -import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.unix.DomainSocketReadMode; import io.netty.channel.unix.FileDescriptor; import io.netty.testsuite.transport.TestsuitePermutation; @@ -52,7 +51,7 @@ public class KQueueDomainSocketFdTest extends AbstractSocketTest { public void testSendRecvFd(ServerBootstrap sb, Bootstrap cb) throws Throwable { final BlockingQueue queue = new LinkedBlockingQueue<>(1); - sb.childHandler(new ChannelInboundHandlerAdapter() { + sb.childHandler(new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { // Create new channel and obtain a file descriptor from it. @@ -66,7 +65,7 @@ public class KQueueDomainSocketFdTest extends AbstractSocketTest { }); } }); - cb.handler(new ChannelInboundHandlerAdapter() { + cb.handler(new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { FileDescriptor fd = (FileDescriptor) msg; diff --git a/transport-native-kqueue/src/test/java/io/netty/channel/kqueue/KQueueServerSocketChannelConfigTest.java b/transport-native-kqueue/src/test/java/io/netty/channel/kqueue/KQueueServerSocketChannelConfigTest.java index 2e04a69d3f..4383bf9cb5 100644 --- a/transport-native-kqueue/src/test/java/io/netty/channel/kqueue/KQueueServerSocketChannelConfigTest.java +++ b/transport-native-kqueue/src/test/java/io/netty/channel/kqueue/KQueueServerSocketChannelConfigTest.java @@ -16,7 +16,7 @@ package io.netty.channel.kqueue; import io.netty.bootstrap.ServerBootstrap; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.EventLoopGroup; import io.netty.channel.MultithreadEventLoopGroup; import org.junit.AfterClass; @@ -42,7 +42,7 @@ public class KQueueServerSocketChannelConfigTest { ServerBootstrap bootstrap = new ServerBootstrap(); ch = (KQueueServerSocketChannel) bootstrap.group(group) .channel(KQueueServerSocketChannel.class) - .childHandler(new ChannelInboundHandlerAdapter()) + .childHandler(new ChannelInboundHandler() { }) .bind(new InetSocketAddress(0)).syncUninterruptibly().channel(); } diff --git a/transport-native-kqueue/src/test/java/io/netty/channel/kqueue/KQueueSocketChannelConfigTest.java b/transport-native-kqueue/src/test/java/io/netty/channel/kqueue/KQueueSocketChannelConfigTest.java index c9a00ba36f..4daf04a322 100644 --- a/transport-native-kqueue/src/test/java/io/netty/channel/kqueue/KQueueSocketChannelConfigTest.java +++ b/transport-native-kqueue/src/test/java/io/netty/channel/kqueue/KQueueSocketChannelConfigTest.java @@ -17,7 +17,7 @@ package io.netty.channel.kqueue; import io.netty.bootstrap.Bootstrap; import io.netty.channel.ChannelException; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.EventLoopGroup; import io.netty.channel.MultithreadEventLoopGroup; import org.junit.After; @@ -59,7 +59,7 @@ public class KQueueSocketChannelConfigTest { Bootstrap bootstrap = new Bootstrap(); ch = (KQueueSocketChannel) bootstrap.group(group) .channel(KQueueSocketChannel.class) - .handler(new ChannelInboundHandlerAdapter()) + .handler(new ChannelInboundHandler() { }) .bind(new InetSocketAddress(0)).syncUninterruptibly().channel(); } diff --git a/transport-native-unix-common-tests/src/main/java/io/netty/channel/unix/tests/DetectPeerCloseWithoutReadTest.java b/transport-native-unix-common-tests/src/main/java/io/netty/channel/unix/tests/DetectPeerCloseWithoutReadTest.java index a8b231f5e1..22a9e3fbfe 100644 --- a/transport-native-unix-common-tests/src/main/java/io/netty/channel/unix/tests/DetectPeerCloseWithoutReadTest.java +++ b/transport-native-unix-common-tests/src/main/java/io/netty/channel/unix/tests/DetectPeerCloseWithoutReadTest.java @@ -21,7 +21,7 @@ import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; @@ -82,7 +82,7 @@ public abstract class DetectPeerCloseWithoutReadTest { Bootstrap cb = new Bootstrap(); cb.group(serverGroup); cb.channel(clientChannel()); - cb.handler(new ChannelInboundHandlerAdapter()); + cb.handler(new ChannelInboundHandler() { }); Channel clientChannel = cb.connect(serverChannel.localAddress()).syncUninterruptibly().channel(); ByteBuf buf = clientChannel.alloc().buffer(expectedBytes); buf.writerIndex(buf.writerIndex() + expectedBytes); @@ -130,7 +130,7 @@ public abstract class DetectPeerCloseWithoutReadTest { sb.childHandler(new ChannelInitializer() { @Override protected void initChannel(Channel ch) { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) { ByteBuf buf = ctx.alloc().buffer(expectedBytes); diff --git a/transport-sctp/src/main/test/io/netty/channel/sctp/SctpLimitStreamsTest.java b/transport-sctp/src/main/test/io/netty/channel/sctp/SctpLimitStreamsTest.java index 3d5abf4c34..aaefe4dfd7 100644 --- a/transport-sctp/src/main/test/io/netty/channel/sctp/SctpLimitStreamsTest.java +++ b/transport-sctp/src/main/test/io/netty/channel/sctp/SctpLimitStreamsTest.java @@ -19,7 +19,6 @@ import com.sun.nio.sctp.SctpStandardSocketOptions; import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.Channel; -import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; import org.junit.Test; diff --git a/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java b/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java index 1d62da35b0..bb77921f4c 100644 --- a/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java +++ b/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java @@ -23,7 +23,7 @@ import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelOption; import io.netty.channel.ChannelPipeline; @@ -245,7 +245,7 @@ public class ServerBootstrap extends AbstractBootstrap, Object>[] childOptions; diff --git a/transport/src/main/java/io/netty/channel/ChannelDuplexHandler.java b/transport/src/main/java/io/netty/channel/ChannelDuplexHandler.java index bc3a915e65..cfa04d8317 100644 --- a/transport/src/main/java/io/netty/channel/ChannelDuplexHandler.java +++ b/transport/src/main/java/io/netty/channel/ChannelDuplexHandler.java @@ -15,8 +15,6 @@ */ package io.netty.channel; -import java.net.SocketAddress; - /** * {@link ChannelHandler} implementation which represents a combination out of a {@link ChannelInboundHandler} and * the {@link ChannelOutboundHandler}. @@ -24,116 +22,6 @@ import java.net.SocketAddress; * It is a good starting point if your {@link ChannelHandler} implementation needs to intercept operations and also * state updates. */ -public class ChannelDuplexHandler extends ChannelInboundHandlerAdapter implements ChannelOutboundHandler { - - /** - * Calls {@link ChannelHandlerContext#bind(SocketAddress, ChannelPromise)} to forward - * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, - ChannelPromise promise) throws Exception { - ctx.bind(localAddress, promise); - } - - /** - * Calls {@link ChannelHandlerContext#connect(SocketAddress, SocketAddress, ChannelPromise)} to forward - * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, - SocketAddress localAddress, ChannelPromise promise) throws Exception { - ctx.connect(remoteAddress, localAddress, promise); - } - - /** - * Calls {@link ChannelHandlerContext#disconnect(ChannelPromise)} to forward - * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) - throws Exception { - ctx.disconnect(promise); - } - - /** - * Calls {@link ChannelHandlerContext#close(ChannelPromise)} to forward - * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { - ctx.close(promise); - } - - /** - * Calls {@link ChannelHandlerContext#register(ChannelPromise)} to forward - * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void register(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { - ctx.register(promise); - } - - /** - * Calls {@link ChannelHandlerContext#deregister(ChannelPromise)} to forward - * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { - ctx.deregister(promise); - } - - /** - * Calls {@link ChannelHandlerContext#read()} to forward - * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void read(ChannelHandlerContext ctx) throws Exception { - ctx.read(); - } - - /** - * Calls {@link ChannelHandlerContext#write(Object, ChannelPromise)} to forward - * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { - ctx.write(msg, promise); - } - - /** - * Calls {@link ChannelHandlerContext#flush()} to forward - * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void flush(ChannelHandlerContext ctx) throws Exception { - ctx.flush(); - } +public class ChannelDuplexHandler extends ChannelHandlerAdapter + implements ChannelInboundHandler, ChannelOutboundHandler { } diff --git a/transport/src/main/java/io/netty/channel/ChannelHandler.java b/transport/src/main/java/io/netty/channel/ChannelHandler.java index 9b3bf8993a..932c1dade1 100644 --- a/transport/src/main/java/io/netty/channel/ChannelHandler.java +++ b/transport/src/main/java/io/netty/channel/ChannelHandler.java @@ -40,8 +40,6 @@ import java.lang.annotation.Target; *

* Alternatively, the following adapter classes are provided for your convenience: *

    - *
  • {@link ChannelInboundHandlerAdapter} to handle inbound I/O events,
  • - *
  • {@link ChannelOutboundHandlerAdapter} to handle outbound I/O operations, and
  • *
  • {@link ChannelDuplexHandler} to handle both inbound and outbound events
  • *
*

@@ -180,13 +178,17 @@ public interface ChannelHandler { /** * Gets called after the {@link ChannelHandler} was added to the actual context and it's ready to handle events. */ - void handlerAdded(ChannelHandlerContext ctx) throws Exception; + default void handlerAdded(ChannelHandlerContext ctx) throws Exception { + // NOOP + } /** * Gets called after the {@link ChannelHandler} was removed from the actual context and it doesn't handle events * anymore. */ - void handlerRemoved(ChannelHandlerContext ctx) throws Exception; + default void handlerRemoved(ChannelHandlerContext ctx) throws Exception { + // NOOP + } /** * Indicates that the same instance of the annotated {@link ChannelHandler} diff --git a/transport/src/main/java/io/netty/channel/ChannelHandlerContext.java b/transport/src/main/java/io/netty/channel/ChannelHandlerContext.java index cb12cfc2b4..ee8708e8aa 100644 --- a/transport/src/main/java/io/netty/channel/ChannelHandlerContext.java +++ b/transport/src/main/java/io/netty/channel/ChannelHandlerContext.java @@ -82,7 +82,7 @@ import java.nio.channels.Channels; * as how many times it is added to pipelines, regardless if it is added to the * same pipeline multiple times or added to different pipelines multiple times: *
- * public class FactorialHandler extends {@link ChannelInboundHandlerAdapter} {
+ * public class FactorialHandler implements {@link ChannelInboundHandler} {
  *
  *   private final {@link AttributeKey}<{@link Integer}> counter = {@link AttributeKey}.valueOf("counter");
  *
diff --git a/transport/src/main/java/io/netty/channel/ChannelInboundHandler.java b/transport/src/main/java/io/netty/channel/ChannelInboundHandler.java
index a0e59e0f68..5fad04be4b 100644
--- a/transport/src/main/java/io/netty/channel/ChannelInboundHandler.java
+++ b/transport/src/main/java/io/netty/channel/ChannelInboundHandler.java
@@ -24,28 +24,43 @@ public interface ChannelInboundHandler extends ChannelHandler {
     /**
      * The {@link Channel} of the {@link ChannelHandlerContext} was registered with its {@link EventLoop}
      */
-    void channelRegistered(ChannelHandlerContext ctx) throws Exception;
+    @Skip
+    default void channelRegistered(ChannelHandlerContext ctx) throws Exception {
+        ctx.fireChannelRegistered();
+    }
 
     /**
      * The {@link Channel} of the {@link ChannelHandlerContext} was unregistered from its {@link EventLoop}
      */
-    void channelUnregistered(ChannelHandlerContext ctx) throws Exception;
+    @Skip
+    default void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
+        ctx.fireChannelUnregistered();
+    }
 
     /**
      * The {@link Channel} of the {@link ChannelHandlerContext} is now active
      */
-    void channelActive(ChannelHandlerContext ctx) throws Exception;
+    @Skip
+    default void channelActive(ChannelHandlerContext ctx) throws Exception {
+        ctx.fireChannelActive();
+    }
 
     /**
      * The {@link Channel} of the {@link ChannelHandlerContext} was registered is now inactive and reached its
      * end of lifetime.
      */
-    void channelInactive(ChannelHandlerContext ctx) throws Exception;
+    @Skip
+    default void channelInactive(ChannelHandlerContext ctx) throws Exception {
+        ctx.fireChannelInactive();
+    }
 
     /**
      * Invoked when the current {@link Channel} has read a message from the peer.
      */
-    void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception;
+    @Skip
+    default void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        ctx.fireChannelRead(msg);
+    }
 
     /**
      * Invoked when the last message read by the current read operation has been consumed by
@@ -53,21 +68,33 @@ public interface ChannelInboundHandler extends ChannelHandler {
      * attempt to read an inbound data from the current {@link Channel} will be made until
      * {@link ChannelHandlerContext#read()} is called.
      */
-    void channelReadComplete(ChannelHandlerContext ctx) throws Exception;
+    @Skip
+    default void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
+        ctx.fireChannelReadComplete();
+    }
 
     /**
      * Gets called if an user event was triggered.
      */
-    void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception;
+    @Skip
+    default void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
+        ctx.fireUserEventTriggered(evt);
+    }
 
     /**
      * Gets called once the writable state of a {@link Channel} changed. You can check the state with
      * {@link Channel#isWritable()}.
      */
-    void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception;
+    @Skip
+    default void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
+        ctx.fireChannelWritabilityChanged();
+    }
 
     /**
      * Gets called if a {@link Throwable} was thrown.
      */
-    void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception;
+    @Skip
+    default void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+        ctx.fireExceptionCaught(cause);
+    }
 }
diff --git a/transport/src/main/java/io/netty/channel/ChannelInboundHandlerAdapter.java b/transport/src/main/java/io/netty/channel/ChannelInboundHandlerAdapter.java
index 0acc18a4d3..5668dc13dc 100644
--- a/transport/src/main/java/io/netty/channel/ChannelInboundHandlerAdapter.java
+++ b/transport/src/main/java/io/netty/channel/ChannelInboundHandlerAdapter.java
@@ -28,115 +28,9 @@ package io.netty.channel;
  * method returns automatically. If you are looking for a {@link ChannelInboundHandler} implementation that
  * releases the received messages automatically, please see {@link SimpleChannelInboundHandler}.
  * 

+ * + * @deprecated use {@link ChannelInboundHandler} directly. */ +@Deprecated public class ChannelInboundHandlerAdapter extends ChannelHandlerAdapter implements ChannelInboundHandler { - - /** - * Calls {@link ChannelHandlerContext#fireChannelRegistered()} to forward - * to the next {@link ChannelInboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void channelRegistered(ChannelHandlerContext ctx) throws Exception { - ctx.fireChannelRegistered(); - } - - /** - * Calls {@link ChannelHandlerContext#fireChannelUnregistered()} to forward - * to the next {@link ChannelInboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void channelUnregistered(ChannelHandlerContext ctx) throws Exception { - ctx.fireChannelUnregistered(); - } - - /** - * Calls {@link ChannelHandlerContext#fireChannelActive()} to forward - * to the next {@link ChannelInboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void channelActive(ChannelHandlerContext ctx) throws Exception { - ctx.fireChannelActive(); - } - - /** - * Calls {@link ChannelHandlerContext#fireChannelInactive()} to forward - * to the next {@link ChannelInboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void channelInactive(ChannelHandlerContext ctx) throws Exception { - ctx.fireChannelInactive(); - } - - /** - * Calls {@link ChannelHandlerContext#fireChannelRead(Object)} to forward - * to the next {@link ChannelInboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { - ctx.fireChannelRead(msg); - } - - /** - * Calls {@link ChannelHandlerContext#fireChannelReadComplete()} to forward - * to the next {@link ChannelInboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { - ctx.fireChannelReadComplete(); - } - - /** - * Calls {@link ChannelHandlerContext#fireUserEventTriggered(Object)} to forward - * to the next {@link ChannelInboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { - ctx.fireUserEventTriggered(evt); - } - - /** - * Calls {@link ChannelHandlerContext#fireChannelWritabilityChanged()} to forward - * to the next {@link ChannelInboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception { - ctx.fireChannelWritabilityChanged(); - } - - /** - * Calls {@link ChannelHandlerContext#fireExceptionCaught(Throwable)} to forward - * to the next {@link ChannelHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) - throws Exception { - ctx.fireExceptionCaught(cause); - } } diff --git a/transport/src/main/java/io/netty/channel/ChannelInitializer.java b/transport/src/main/java/io/netty/channel/ChannelInitializer.java index c16050a082..810891b233 100644 --- a/transport/src/main/java/io/netty/channel/ChannelInitializer.java +++ b/transport/src/main/java/io/netty/channel/ChannelInitializer.java @@ -47,7 +47,7 @@ import io.netty.util.internal.logging.InternalLoggerFactory; * @param A sub-type of {@link Channel} */ @Sharable -public abstract class ChannelInitializer extends ChannelInboundHandlerAdapter { +public abstract class ChannelInitializer implements ChannelInboundHandler { private static final InternalLogger logger = InternalLoggerFactory.getInstance(ChannelInitializer.class); diff --git a/transport/src/main/java/io/netty/channel/ChannelOutboundHandler.java b/transport/src/main/java/io/netty/channel/ChannelOutboundHandler.java index 254f7ae9a0..78e80d264e 100644 --- a/transport/src/main/java/io/netty/channel/ChannelOutboundHandler.java +++ b/transport/src/main/java/io/netty/channel/ChannelOutboundHandler.java @@ -29,7 +29,10 @@ public interface ChannelOutboundHandler extends ChannelHandler { * @param promise the {@link ChannelPromise} to notify once the operation completes * @throws Exception thrown if an error occurs */ - void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception; + @Skip + default void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception { + ctx.bind(localAddress, promise); + } /** * Called once a connect operation is made. @@ -40,9 +43,12 @@ public interface ChannelOutboundHandler extends ChannelHandler { * @param promise the {@link ChannelPromise} to notify once the operation completes * @throws Exception thrown if an error occurs */ - void connect( + @Skip + default void connect( ChannelHandlerContext ctx, SocketAddress remoteAddress, - SocketAddress localAddress, ChannelPromise promise) throws Exception; + SocketAddress localAddress, ChannelPromise promise) throws Exception { + ctx.connect(remoteAddress, localAddress, promise); + } /** * Called once a disconnect operation is made. @@ -51,7 +57,10 @@ public interface ChannelOutboundHandler extends ChannelHandler { * @param promise the {@link ChannelPromise} to notify once the operation completes * @throws Exception thrown if an error occurs */ - void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception; + @Skip + default void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { + ctx.disconnect(promise); + } /** * Called once a close operation is made. @@ -60,7 +69,10 @@ public interface ChannelOutboundHandler extends ChannelHandler { * @param promise the {@link ChannelPromise} to notify once the operation completes * @throws Exception thrown if an error occurs */ - void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception; + @Skip + default void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { + ctx.close(promise); + } /** * Called once a register operation is made to register for IO on the {@link EventLoop}. @@ -69,7 +81,10 @@ public interface ChannelOutboundHandler extends ChannelHandler { * @param promise the {@link ChannelPromise} to notify once the operation completes * @throws Exception thrown if an error occurs */ - void register(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception; + @Skip + default void register(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { + ctx.register(promise); + } /** * Called once a deregister operation is made from the current registered {@link EventLoop}. @@ -78,12 +93,18 @@ public interface ChannelOutboundHandler extends ChannelHandler { * @param promise the {@link ChannelPromise} to notify once the operation completes * @throws Exception thrown if an error occurs */ - void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception; + @Skip + default void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { + ctx.deregister(promise); + } /** * Intercepts {@link ChannelHandlerContext#read()}. */ - void read(ChannelHandlerContext ctx) throws Exception; + @Skip + default void read(ChannelHandlerContext ctx) throws Exception { + ctx.read(); + } /** * Called once a write operation is made. The write operation will write the messages through the @@ -95,7 +116,10 @@ public interface ChannelOutboundHandler extends ChannelHandler { * @param promise the {@link ChannelPromise} to notify once the operation completes * @throws Exception thrown if an error occurs */ - void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception; + @Skip + default void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { + ctx.write(msg, promise); + } /** * Called once a flush operation is made. The flush operation will try to flush out all previous written messages @@ -104,5 +128,8 @@ public interface ChannelOutboundHandler extends ChannelHandler { * @param ctx the {@link ChannelHandlerContext} for which the flush operation is made * @throws Exception thrown if an error occurs */ - void flush(ChannelHandlerContext ctx) throws Exception; + @Skip + default void flush(ChannelHandlerContext ctx) throws Exception { + ctx.flush(); + } } diff --git a/transport/src/main/java/io/netty/channel/ChannelOutboundHandlerAdapter.java b/transport/src/main/java/io/netty/channel/ChannelOutboundHandlerAdapter.java index 674a6ca7d3..5f63d4dd39 100644 --- a/transport/src/main/java/io/netty/channel/ChannelOutboundHandlerAdapter.java +++ b/transport/src/main/java/io/netty/channel/ChannelOutboundHandlerAdapter.java @@ -15,123 +15,12 @@ */ package io.netty.channel; -import java.net.SocketAddress; - /** * Skeleton implementation of a {@link ChannelOutboundHandler}. This implementation just forwards each method call via * the {@link ChannelHandlerContext}. + * + * @deprecated use {@link ChannelOutboundHandler} directly. */ +@Deprecated public class ChannelOutboundHandlerAdapter extends ChannelHandlerAdapter implements ChannelOutboundHandler { - - /** - * Calls {@link ChannelHandlerContext#bind(SocketAddress, ChannelPromise)} to forward - * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, - ChannelPromise promise) throws Exception { - ctx.bind(localAddress, promise); - } - - /** - * Calls {@link ChannelHandlerContext#connect(SocketAddress, SocketAddress, ChannelPromise)} to forward - * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, - SocketAddress localAddress, ChannelPromise promise) throws Exception { - ctx.connect(remoteAddress, localAddress, promise); - } - - /** - * Calls {@link ChannelHandlerContext#disconnect(ChannelPromise)} to forward - * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) - throws Exception { - ctx.disconnect(promise); - } - - /** - * Calls {@link ChannelHandlerContext#close(ChannelPromise)} to forward - * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void close(ChannelHandlerContext ctx, ChannelPromise promise) - throws Exception { - ctx.close(promise); - } - - /** - * Calls {@link ChannelHandlerContext#register(ChannelPromise)} to forward - * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void register(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { - ctx.register(promise); - } - - /** - * Calls {@link ChannelHandlerContext#deregister(ChannelPromise)} to forward - * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { - ctx.deregister(promise); - } - - /** - * Calls {@link ChannelHandlerContext#read()} to forward - * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void read(ChannelHandlerContext ctx) throws Exception { - ctx.read(); - } - - /** - * Calls {@link ChannelHandlerContext#write(Object, ChannelPromise)} to forward - * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { - ctx.write(msg, promise); - } - - /** - * Calls {@link ChannelHandlerContext#flush()} to forward - * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}. - * - * Sub-classes may override this method to change behavior. - */ - @Skip - @Override - public void flush(ChannelHandlerContext ctx) throws Exception { - ctx.flush(); - } } diff --git a/transport/src/main/java/io/netty/channel/ChannelPipeline.java b/transport/src/main/java/io/netty/channel/ChannelPipeline.java index 386c0c76ed..96045c62f9 100644 --- a/transport/src/main/java/io/netty/channel/ChannelPipeline.java +++ b/transport/src/main/java/io/netty/channel/ChannelPipeline.java @@ -156,7 +156,7 @@ import java.util.NoSuchElementException; * and the following example shows how the event propagation is usually done: * *
- * public class MyInboundHandler extends {@link ChannelInboundHandlerAdapter} {
+ * public class MyInboundHandler implements {@link ChannelInboundHandler} {
  *     {@code @Override}
  *     public void channelActive({@link ChannelHandlerContext} ctx) {
  *         System.out.println("Connected!");
@@ -164,7 +164,7 @@ import java.util.NoSuchElementException;
  *     }
  * }
  *
- * public class MyOutboundHandler extends {@link ChannelOutboundHandlerAdapter} {
+ * public class MyOutboundHandler implements {@link ChannelOutboundHandler} {
  *     {@code @Override}
  *     public void close({@link ChannelHandlerContext} ctx, {@link ChannelPromise} promise) {
  *         System.out.println("Closing ..");
diff --git a/transport/src/main/java/io/netty/channel/SimpleChannelInboundHandler.java b/transport/src/main/java/io/netty/channel/SimpleChannelInboundHandler.java
index ddc516e819..65251a1790 100644
--- a/transport/src/main/java/io/netty/channel/SimpleChannelInboundHandler.java
+++ b/transport/src/main/java/io/netty/channel/SimpleChannelInboundHandler.java
@@ -19,7 +19,7 @@ import io.netty.util.ReferenceCountUtil;
 import io.netty.util.internal.TypeParameterMatcher;
 
 /**
- * {@link ChannelInboundHandlerAdapter} which allows to explicit only handle a specific type of messages.
+ * {@link ChannelInboundHandler} which allows to explicit only handle a specific type of messages.
  *
  * For example here is an implementation which only handle {@link String} messages.
  *
@@ -45,7 +45,7 @@ import io.netty.util.internal.TypeParameterMatcher;
  * {@code messageReceived(ChannelHandlerContext, I)} in 5.0.
  * 

*/ -public abstract class SimpleChannelInboundHandler extends ChannelInboundHandlerAdapter { +public abstract class SimpleChannelInboundHandler implements ChannelInboundHandler { private final TypeParameterMatcher matcher; private final boolean autoRelease; diff --git a/transport/src/main/java/io/netty/channel/SimpleUserEventChannelHandler.java b/transport/src/main/java/io/netty/channel/SimpleUserEventChannelHandler.java index c976c2d26c..c26fb807ad 100644 --- a/transport/src/main/java/io/netty/channel/SimpleUserEventChannelHandler.java +++ b/transport/src/main/java/io/netty/channel/SimpleUserEventChannelHandler.java @@ -19,7 +19,7 @@ import io.netty.util.ReferenceCountUtil; import io.netty.util.internal.TypeParameterMatcher; /** - * {@link ChannelInboundHandlerAdapter} which allows to conveniently only handle a specific type of user events. + * {@link ChannelInboundHandler} which allows to conveniently only handle a specific type of user events. * * For example, here is an implementation which only handle {@link String} user events. * @@ -39,7 +39,7 @@ import io.netty.util.internal.TypeParameterMatcher; * {@link ReferenceCountUtil#release(Object)}. In this case you may need to use * {@link ReferenceCountUtil#retain(Object)} if you pass the object to the next handler in the {@link ChannelPipeline}. */ -public abstract class SimpleUserEventChannelHandler extends ChannelInboundHandlerAdapter { +public abstract class SimpleUserEventChannelHandler implements ChannelInboundHandler { private final TypeParameterMatcher matcher; private final boolean autoRelease; diff --git a/transport/src/main/java/io/netty/channel/group/ChannelGroup.java b/transport/src/main/java/io/netty/channel/group/ChannelGroup.java index 8d6944f485..1fd7f93b5a 100644 --- a/transport/src/main/java/io/netty/channel/group/ChannelGroup.java +++ b/transport/src/main/java/io/netty/channel/group/ChannelGroup.java @@ -22,7 +22,7 @@ import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelId; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.EventLoop; import io.netty.channel.ServerChannel; import io.netty.util.CharsetUtil; @@ -82,12 +82,12 @@ import java.util.Set; * allChannels.close().awaitUninterruptibly(); * } * - * public class MyHandler extends {@link ChannelInboundHandlerAdapter} { + * public class MyHandler implements {@link ChannelInboundHandler} { * {@code @Override} * public void channelActive({@link ChannelHandlerContext} ctx) { * // closed on shutdown. * allChannels.add(ctx.channel()); - * super.channelActive(ctx); + * ctx.fireChannelActive(); * } * } *
diff --git a/transport/src/test/java/io/netty/bootstrap/BootstrapTest.java b/transport/src/test/java/io/netty/bootstrap/BootstrapTest.java index eaa6c48d90..e35cc545ae 100644 --- a/transport/src/test/java/io/netty/bootstrap/BootstrapTest.java +++ b/transport/src/test/java/io/netty/bootstrap/BootstrapTest.java @@ -21,8 +21,7 @@ import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandler.Sharable; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandler; -import io.netty.channel.ChannelInboundHandlerAdapter; -import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelOutboundHandler; import io.netty.channel.ChannelPromise; import io.netty.channel.EventLoopGroup; import io.netty.channel.MultithreadEventLoopGroup; @@ -282,7 +281,7 @@ public class BootstrapTest { assertThat(connectFuture.channel(), is(not(nullValue()))); } - private static final class LateRegisterHandler extends ChannelOutboundHandlerAdapter { + private static final class LateRegisterHandler implements ChannelOutboundHandler { private final CountDownLatch latch = new CountDownLatch(1); private ChannelPromise registerPromise; @@ -297,7 +296,7 @@ public class BootstrapTest { registerPromise.tryFailure(future.cause()); } }); - super.register(ctx, newPromise); + ctx.register(newPromise); } ChannelPromise registerPromise() throws InterruptedException { @@ -307,7 +306,7 @@ public class BootstrapTest { } @Sharable - private static final class DummyHandler extends ChannelInboundHandlerAdapter { } + private static final class DummyHandler implements ChannelInboundHandler { } private static final class TestAddressResolverGroup extends AddressResolverGroup { diff --git a/transport/src/test/java/io/netty/bootstrap/ServerBootstrapTest.java b/transport/src/test/java/io/netty/bootstrap/ServerBootstrapTest.java index 02fe83a7d1..818a56d9c4 100644 --- a/transport/src/test/java/io/netty/bootstrap/ServerBootstrapTest.java +++ b/transport/src/test/java/io/netty/bootstrap/ServerBootstrapTest.java @@ -19,7 +19,7 @@ import io.netty.channel.Channel; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerAdapter; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.MultithreadEventLoopGroup; import io.netty.channel.EventLoopGroup; @@ -47,7 +47,7 @@ public class ServerBootstrapTest { ServerBootstrap sb = new ServerBootstrap(); sb.channel(LocalServerChannel.class) .group(group) - .childHandler(new ChannelInboundHandlerAdapter()) + .childHandler(new ChannelInboundHandler() { }) .handler(new ChannelHandlerAdapter() { @Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { @@ -83,17 +83,17 @@ public class ServerBootstrapTest { final CountDownLatch readLatch = new CountDownLatch(1); final CountDownLatch initLatch = new CountDownLatch(1); - final ChannelHandler handler = new ChannelInboundHandlerAdapter() { + final ChannelHandler handler = new ChannelInboundHandler() { @Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { initLatch.countDown(); - super.handlerAdded(ctx); + ctx.fireChannelActive(); } @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { readLatch.countDown(); - super.channelRead(ctx, msg); + ctx.fireChannelRead(msg); } }; @@ -104,7 +104,7 @@ public class ServerBootstrapTest { ServerBootstrap sb = new ServerBootstrap(); sb.channel(LocalServerChannel.class) .group(group) - .childHandler(new ChannelInboundHandlerAdapter()); + .childHandler(new ChannelInboundHandler() { }); if (channelInitializer) { sb.handler(new ChannelInitializer() { @Override @@ -119,7 +119,7 @@ public class ServerBootstrapTest { Bootstrap cb = new Bootstrap(); cb.group(group) .channel(LocalChannel.class) - .handler(new ChannelInboundHandlerAdapter()); + .handler(new ChannelInboundHandler() { }); sch = sb.bind(addr).syncUninterruptibly().channel(); diff --git a/transport/src/test/java/io/netty/channel/AbstractEventLoopTest.java b/transport/src/test/java/io/netty/channel/AbstractEventLoopTest.java index ef6fa7c9ce..843705b731 100644 --- a/transport/src/test/java/io/netty/channel/AbstractEventLoopTest.java +++ b/transport/src/test/java/io/netty/channel/AbstractEventLoopTest.java @@ -36,7 +36,7 @@ public abstract class AbstractEventLoopTest { ServerBootstrap b = new ServerBootstrap(); b.group(loop) .channel(newChannel()) - .childHandler(new ChannelInboundHandlerAdapter()); + .childHandler(new ChannelInboundHandler() { }); // Not close the Channel to ensure the EventLoop is still shutdown in time. b.bind(0).sync().channel(); diff --git a/transport/src/test/java/io/netty/channel/ChannelInitializerTest.java b/transport/src/test/java/io/netty/channel/ChannelInitializerTest.java index 3360d4ed14..119a0249fd 100644 --- a/transport/src/test/java/io/netty/channel/ChannelInitializerTest.java +++ b/transport/src/test/java/io/netty/channel/ChannelInitializerTest.java @@ -57,7 +57,7 @@ public class ChannelInitializerTest { client = new Bootstrap() .group(group) .channel(LocalChannel.class) - .handler(new ChannelInboundHandlerAdapter()); + .handler(new ChannelInboundHandler() { }); testHandler = new InspectableHandler(); } @@ -109,10 +109,10 @@ public class ChannelInitializerTest { @Test public void testChannelInitializerInInitializerCorrectOrdering() { - final ChannelInboundHandlerAdapter handler1 = new ChannelInboundHandlerAdapter(); - final ChannelInboundHandlerAdapter handler2 = new ChannelInboundHandlerAdapter(); - final ChannelInboundHandlerAdapter handler3 = new ChannelInboundHandlerAdapter(); - final ChannelInboundHandlerAdapter handler4 = new ChannelInboundHandlerAdapter(); + final ChannelInboundHandler handler1 = new ChannelInboundHandler() { }; + final ChannelInboundHandler handler2 = new ChannelInboundHandler() { }; + final ChannelInboundHandler handler3 = new ChannelInboundHandler() { }; + final ChannelInboundHandler handler4 = new ChannelInboundHandler() { }; client.handler(new ChannelInitializer() { @Override @@ -150,7 +150,7 @@ public class ChannelInitializerTest { @Test public void testChannelInitializerReentrance() { final AtomicInteger registeredCalled = new AtomicInteger(0); - final ChannelInboundHandlerAdapter handler1 = new ChannelInboundHandlerAdapter() { + final ChannelInboundHandler handler1 = new ChannelInboundHandler() { @Override public void channelRegistered(ChannelHandlerContext ctx) throws Exception { registeredCalled.incrementAndGet(); diff --git a/transport/src/test/java/io/netty/channel/ChannelOutboundBufferTest.java b/transport/src/test/java/io/netty/channel/ChannelOutboundBufferTest.java index c769cbf963..d59ae30ca8 100644 --- a/transport/src/test/java/io/netty/channel/ChannelOutboundBufferTest.java +++ b/transport/src/test/java/io/netty/channel/ChannelOutboundBufferTest.java @@ -237,7 +237,7 @@ public class ChannelOutboundBufferTest { @Test public void testWritability() { final StringBuilder buf = new StringBuilder(); - EmbeddedChannel ch = new EmbeddedChannel(new ChannelInboundHandlerAdapter() { + EmbeddedChannel ch = new EmbeddedChannel(new ChannelInboundHandler() { @Override public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception { buf.append(ctx.channel().isWritable()); @@ -272,7 +272,7 @@ public class ChannelOutboundBufferTest { @Test public void testUserDefinedWritability() { final StringBuilder buf = new StringBuilder(); - EmbeddedChannel ch = new EmbeddedChannel(new ChannelInboundHandlerAdapter() { + EmbeddedChannel ch = new EmbeddedChannel(new ChannelInboundHandler() { @Override public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception { buf.append(ctx.channel().isWritable()); @@ -306,7 +306,7 @@ public class ChannelOutboundBufferTest { @Test public void testUserDefinedWritability2() { final StringBuilder buf = new StringBuilder(); - EmbeddedChannel ch = new EmbeddedChannel(new ChannelInboundHandlerAdapter() { + EmbeddedChannel ch = new EmbeddedChannel(new ChannelInboundHandler() { @Override public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception { buf.append(ctx.channel().isWritable()); @@ -346,7 +346,7 @@ public class ChannelOutboundBufferTest { @Test public void testMixedWritability() { final StringBuilder buf = new StringBuilder(); - EmbeddedChannel ch = new EmbeddedChannel(new ChannelInboundHandlerAdapter() { + EmbeddedChannel ch = new EmbeddedChannel(new ChannelInboundHandler() { @Override public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception { buf.append(ctx.channel().isWritable()); diff --git a/transport/src/test/java/io/netty/channel/CombinedChannelDuplexHandlerTest.java b/transport/src/test/java/io/netty/channel/CombinedChannelDuplexHandlerTest.java index 676531ce58..f733003fc5 100644 --- a/transport/src/test/java/io/netty/channel/CombinedChannelDuplexHandlerTest.java +++ b/transport/src/test/java/io/netty/channel/CombinedChannelDuplexHandlerTest.java @@ -57,7 +57,7 @@ public class CombinedChannelDuplexHandlerTest { public void testInboundRemoveBeforeAdded() { CombinedChannelDuplexHandler handler = new CombinedChannelDuplexHandler<>( - new ChannelInboundHandlerAdapter(), new ChannelOutboundHandlerAdapter()); + new ChannelInboundHandler() { }, new ChannelOutboundHandler() { }); handler.removeInboundHandler(); } @@ -65,20 +65,20 @@ public class CombinedChannelDuplexHandlerTest { public void testOutboundRemoveBeforeAdded() { CombinedChannelDuplexHandler handler = new CombinedChannelDuplexHandler<>( - new ChannelInboundHandlerAdapter(), new ChannelOutboundHandlerAdapter()); + new ChannelInboundHandler() { }, new ChannelOutboundHandler() { }); handler.removeOutboundHandler(); } @Test(expected = IllegalArgumentException.class) public void testInboundHandlerImplementsOutboundHandler() { new CombinedChannelDuplexHandler( - new ChannelDuplexHandler(), new ChannelOutboundHandlerAdapter()); + new ChannelDuplexHandler(), new ChannelOutboundHandler() { }); } @Test(expected = IllegalArgumentException.class) public void testOutboundHandlerImplementsInboundHandler() { new CombinedChannelDuplexHandler( - new ChannelInboundHandlerAdapter(), new ChannelDuplexHandler()); + new ChannelInboundHandler() { }, new ChannelDuplexHandler()); } @Test(expected = IllegalStateException.class) @@ -93,7 +93,7 @@ public class CombinedChannelDuplexHandlerTest { final Exception exception = new Exception(); final Queue queue = new ArrayDeque<>(); - ChannelInboundHandler inboundHandler = new ChannelInboundHandlerAdapter() { + ChannelInboundHandler inboundHandler = new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { assertSame(exception, cause); @@ -101,7 +101,7 @@ public class CombinedChannelDuplexHandlerTest { ctx.fireExceptionCaught(cause); } }; - ChannelInboundHandler lastHandler = new ChannelInboundHandlerAdapter() { + ChannelInboundHandler lastHandler = new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { assertSame(exception, cause); @@ -110,7 +110,7 @@ public class CombinedChannelDuplexHandlerTest { }; EmbeddedChannel channel = new EmbeddedChannel( new CombinedChannelDuplexHandler<>( - inboundHandler, new ChannelOutboundHandlerAdapter()), lastHandler); + inboundHandler, new ChannelOutboundHandler() { }), lastHandler); channel.pipeline().fireExceptionCaught(exception); assertFalse(channel.finish()); assertSame(inboundHandler, queue.poll()); @@ -122,7 +122,7 @@ public class CombinedChannelDuplexHandlerTest { public void testInboundEvents() { final Queue queue = new ArrayDeque<>(); - ChannelInboundHandler inboundHandler = new ChannelInboundHandlerAdapter() { + ChannelInboundHandler inboundHandler = new ChannelInboundHandler() { @Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { queue.add(Event.HANDLER_ADDED); @@ -181,7 +181,7 @@ public class CombinedChannelDuplexHandlerTest { CombinedChannelDuplexHandler handler = new CombinedChannelDuplexHandler<>( - inboundHandler, new ChannelOutboundHandlerAdapter()); + inboundHandler, new ChannelOutboundHandler() { }); EmbeddedChannel channel = new EmbeddedChannel(handler); channel.pipeline().fireChannelWritabilityChanged(); @@ -216,8 +216,8 @@ public class CombinedChannelDuplexHandlerTest { public void testOutboundEvents() { final Queue queue = new ArrayDeque<>(); - ChannelInboundHandler inboundHandler = new ChannelInboundHandlerAdapter(); - ChannelOutboundHandler outboundHandler = new ChannelOutboundHandlerAdapter() { + ChannelInboundHandler inboundHandler = new ChannelInboundHandler() { }; + ChannelOutboundHandler outboundHandler = new ChannelOutboundHandler() { @Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { queue.add(Event.HANDLER_ADDED); @@ -315,7 +315,7 @@ public class CombinedChannelDuplexHandlerTest { @Test(timeout = 3000) public void testPromisesPassed() { - ChannelOutboundHandler outboundHandler = new ChannelOutboundHandlerAdapter() { + ChannelOutboundHandler outboundHandler = new ChannelOutboundHandler() { @Override public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception { @@ -350,7 +350,8 @@ public class CombinedChannelDuplexHandlerTest { }; EmbeddedChannel ch = new EmbeddedChannel(outboundHandler, new CombinedChannelDuplexHandler( - new ChannelInboundHandlerAdapter(), new ChannelOutboundHandlerAdapter())); + new ChannelInboundHandler() { + }, new ChannelOutboundHandler() { })); ChannelPipeline pipeline = ch.pipeline(); ChannelPromise promise = ch.newPromise(); diff --git a/transport/src/test/java/io/netty/channel/DefaultChannelPipelineTest.java b/transport/src/test/java/io/netty/channel/DefaultChannelPipelineTest.java index 1794a3c41f..f2c12f80d1 100644 --- a/transport/src/test/java/io/netty/channel/DefaultChannelPipelineTest.java +++ b/transport/src/test/java/io/netty/channel/DefaultChannelPipelineTest.java @@ -80,7 +80,7 @@ public class DefaultChannelPipelineTest { final AtomicReference peerRef = new AtomicReference<>(); ServerBootstrap sb = new ServerBootstrap(); sb.group(group).channel(LocalServerChannel.class); - sb.childHandler(new ChannelInboundHandlerAdapter() { + sb.childHandler(new ChannelInboundHandler() { @Override public void channelRegistered(ChannelHandlerContext ctx) throws Exception { peerRef.set(ctx.channel()); @@ -145,7 +145,7 @@ public class DefaultChannelPipelineTest { assertTrue(handler.called); } - private static final class StringInboundHandler extends ChannelInboundHandlerAdapter { + private static final class StringInboundHandler implements ChannelInboundHandler { boolean called; @Override @@ -216,7 +216,10 @@ public class DefaultChannelPipelineTest { assertNull(pipeline.removeIfExists("handlerXXX")); assertNull(pipeline.removeIfExists(handler2)); - assertNull(pipeline.removeIfExists(ChannelOutboundHandlerAdapter.class)); + + class NonExistingHandler implements ChannelHandler { } + + assertNull(pipeline.removeIfExists(NonExistingHandler.class)); assertNotNull(pipeline.get("handler1")); } @@ -276,7 +279,7 @@ public class DefaultChannelPipelineTest { pipeline.addLast(new ChannelInitializer() { @Override protected void initChannel(Channel ch) throws Exception { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void channelRegistered(ChannelHandlerContext ctx) throws Exception { latch.countDown(); @@ -802,7 +805,7 @@ public class DefaultChannelPipelineTest { pipeline1.channel().register().addListener((ChannelFutureListener) future -> { ChannelPipeline pipeline = future.channel().pipeline(); final AtomicBoolean handlerAddedCalled = new AtomicBoolean(); - pipeline.addLast(new ChannelInboundHandlerAdapter() { + pipeline.addLast(new ChannelInboundHandler() { @Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { handlerAddedCalled.set(true); @@ -890,7 +893,7 @@ public class DefaultChannelPipelineTest { final CountDownLatch latch = new CountDownLatch(1); - pipeline.addLast(new ChannelInboundHandlerAdapter() { + pipeline.addLast(new ChannelInboundHandler() { @Override public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { // Block just for a bit so we have a chance to trigger the race mentioned in the issue. @@ -902,7 +905,7 @@ public class DefaultChannelPipelineTest { // should call handlerRemoved(...) if and only if handlerAdded(...) was called for the handler before. pipeline.close(); - pipeline.addLast(new ChannelInboundHandlerAdapter() { + pipeline.addLast(new ChannelInboundHandler() { private boolean handerAddedCalled; @Override @@ -1096,7 +1099,7 @@ public class DefaultChannelPipelineTest { } } - final class OutboundCalledHandler extends ChannelOutboundHandlerAdapter { + final class OutboundCalledHandler implements ChannelOutboundHandler { private static final int MASK_BIND = 1; private static final int MASK_CONNECT = 1 << 1; private static final int MASK_DISCONNECT = 1 << 2; @@ -1193,7 +1196,7 @@ public class DefaultChannelPipelineTest { } } - final class InboundCalledHandler extends ChannelInboundHandlerAdapter { + final class InboundCalledHandler implements ChannelInboundHandler { private static final int MASK_CHANNEL_REGISTER = 1; private static final int MASK_CHANNEL_UNREGISTER = 1 << 1; @@ -1384,7 +1387,7 @@ public class DefaultChannelPipelineTest { final CountDownLatch doneLatch = new CountDownLatch(1); Runnable r = () -> { - pipeline.addLast(new ChannelInboundHandlerAdapter() { + pipeline.addLast(new ChannelInboundHandler() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { if (evt == userEvent) { @@ -1430,7 +1433,7 @@ public class DefaultChannelPipelineTest { @Override public void run() { - pipeline.addLast(new ChannelInboundHandlerAdapter()); + pipeline.addLast(new ChannelInboundHandler() { }); latch.countDown(); } } @@ -1459,7 +1462,7 @@ public class DefaultChannelPipelineTest { } } - private static final class CheckExceptionHandler extends ChannelInboundHandlerAdapter { + private static final class CheckExceptionHandler implements ChannelInboundHandler { private final Throwable expected; private final Promise promise; @@ -1488,7 +1491,7 @@ public class DefaultChannelPipelineTest { fail("handler was not one of the expected handlers"); } - private static final class CheckOrderHandler extends ChannelInboundHandlerAdapter { + private static final class CheckOrderHandler implements ChannelInboundHandler { private final Queue addedQueue; private final Queue removedQueue; private final AtomicReference error = new AtomicReference<>(); diff --git a/transport/src/test/java/io/netty/channel/PendingWriteQueueTest.java b/transport/src/test/java/io/netty/channel/PendingWriteQueueTest.java index 218a1bc154..ce5277e3b3 100644 --- a/transport/src/test/java/io/netty/channel/PendingWriteQueueTest.java +++ b/transport/src/test/java/io/netty/channel/PendingWriteQueueTest.java @@ -89,7 +89,7 @@ public class PendingWriteQueueTest { final AtomicReference queueRef = new AtomicReference<>(); final ByteBuf msg = Unpooled.copiedBuffer("test", CharsetUtil.US_ASCII); - final EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandlerAdapter() { + final EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandler() { @Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { ctxRef.set(ctx); @@ -214,13 +214,13 @@ public class PendingWriteQueueTest { @Test public void testRemoveAndWriteAllReentrantWrite() { - EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandlerAdapter() { + EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandler() { @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) { // Convert to writeAndFlush(...) so the promise will be notified by the transport. ctx.writeAndFlush(msg, promise); } - }, new ChannelOutboundHandlerAdapter()); + }, new ChannelOutboundHandler() { }); final PendingWriteQueue queue = new PendingWriteQueue(channel.pipeline().lastContext()); @@ -246,13 +246,13 @@ public class PendingWriteQueueTest { @Test public void testRemoveAndWriteAllWithVoidPromise() { - EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandlerAdapter() { + EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandler() { @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) { // Convert to writeAndFlush(...) so the promise will be notified by the transport. ctx.writeAndFlush(msg, promise); } - }, new ChannelOutboundHandlerAdapter()); + }, new ChannelOutboundHandler() { }); final PendingWriteQueue queue = new PendingWriteQueue(channel.pipeline().lastContext()); diff --git a/transport/src/test/java/io/netty/channel/ReentrantChannelTest.java b/transport/src/test/java/io/netty/channel/ReentrantChannelTest.java index 87167e6177..1e579b248c 100644 --- a/transport/src/test/java/io/netty/channel/ReentrantChannelTest.java +++ b/transport/src/test/java/io/netty/channel/ReentrantChannelTest.java @@ -116,7 +116,7 @@ public class ReentrantChannelTest extends BaseChannelTest { clientChannel.config().setWriteBufferLowWaterMark(512); clientChannel.config().setWriteBufferHighWaterMark(1024); - clientChannel.pipeline().addLast(new ChannelInboundHandlerAdapter() { + clientChannel.pipeline().addLast(new ChannelInboundHandler() { @Override public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception { if (!ctx.channel().isWritable()) { @@ -164,7 +164,7 @@ public class ReentrantChannelTest extends BaseChannelTest { Channel clientChannel = cb.connect(addr).sync().channel(); - clientChannel.pipeline().addLast(new ChannelOutboundHandlerAdapter() { + clientChannel.pipeline().addLast(new ChannelOutboundHandler() { int writeCount; int flushCount; @@ -175,7 +175,7 @@ public class ReentrantChannelTest extends BaseChannelTest { writeCount++; ctx.channel().flush(); } - super.write(ctx, msg, promise); + ctx.write(msg, promise); } @Override @@ -184,7 +184,7 @@ public class ReentrantChannelTest extends BaseChannelTest { flushCount++; ctx.channel().write(createTestBuf(2000)); } - super.flush(ctx); + ctx.flush(); } }); @@ -221,12 +221,12 @@ public class ReentrantChannelTest extends BaseChannelTest { Channel clientChannel = cb.connect(addr).sync().channel(); - clientChannel.pipeline().addLast(new ChannelOutboundHandlerAdapter() { + clientChannel.pipeline().addLast(new ChannelOutboundHandler() { @Override public void write(final ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { promise.addListener(future -> ctx.channel().close()); - super.write(ctx, msg, promise); + ctx.write(msg, promise); ctx.channel().flush(); } }); @@ -251,14 +251,14 @@ public class ReentrantChannelTest extends BaseChannelTest { Channel clientChannel = cb.connect(addr).sync().channel(); - clientChannel.pipeline().addLast(new ChannelOutboundHandlerAdapter() { + clientChannel.pipeline().addLast(new ChannelOutboundHandler() { @Override public void flush(ChannelHandlerContext ctx) throws Exception { throw new Exception("intentional failure"); } - }, new ChannelInboundHandlerAdapter() { + }, new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { ctx.close(); diff --git a/transport/src/test/java/io/netty/channel/SimpleUserEventChannelHandlerTest.java b/transport/src/test/java/io/netty/channel/SimpleUserEventChannelHandlerTest.java index 6f3509b964..0023a632c2 100644 --- a/transport/src/test/java/io/netty/channel/SimpleUserEventChannelHandlerTest.java +++ b/transport/src/test/java/io/netty/channel/SimpleUserEventChannelHandlerTest.java @@ -85,7 +85,7 @@ public class SimpleUserEventChannelHandlerTest { } } - static final class AllEventCatcher extends ChannelInboundHandlerAdapter { + static final class AllEventCatcher implements ChannelInboundHandler { public List caughtEvents; diff --git a/transport/src/test/java/io/netty/channel/embedded/EmbeddedChannelTest.java b/transport/src/test/java/io/netty/channel/embedded/EmbeddedChannelTest.java index 9500a480ec..eb9d2b33a2 100644 --- a/transport/src/test/java/io/netty/channel/embedded/EmbeddedChannelTest.java +++ b/transport/src/test/java/io/netty/channel/embedded/EmbeddedChannelTest.java @@ -22,6 +22,8 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import io.netty.channel.ChannelInboundHandler; +import io.netty.channel.ChannelOutboundHandler; import io.netty.channel.ChannelOutboundInvoker; import java.nio.channels.ClosedChannelException; import java.util.ArrayDeque; @@ -43,9 +45,7 @@ import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerAdapter; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelId; -import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelInitializer; -import io.netty.channel.ChannelOutboundHandlerAdapter; import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelPromise; import io.netty.util.ReferenceCountUtil; @@ -89,7 +89,7 @@ public class EmbeddedChannelTest { final Integer first = 1; final Integer second = 2; - final ChannelHandler handler = new ChannelInboundHandlerAdapter() { + final ChannelHandler handler = new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { ctx.fireChannelRead(first); @@ -114,7 +114,7 @@ public class EmbeddedChannelTest { @SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testScheduling() throws Exception { - EmbeddedChannel ch = new EmbeddedChannel(new ChannelInboundHandlerAdapter()); + EmbeddedChannel ch = new EmbeddedChannel(new ChannelInboundHandler() { }); final CountDownLatch latch = new CountDownLatch(2); ScheduledFuture future = ch.eventLoop().schedule(latch::countDown, 1, TimeUnit.SECONDS); future.addListener((FutureListener) future1 -> latch.countDown()); @@ -129,7 +129,7 @@ public class EmbeddedChannelTest { @Test public void testScheduledCancelled() throws Exception { - EmbeddedChannel ch = new EmbeddedChannel(new ChannelInboundHandlerAdapter()); + EmbeddedChannel ch = new EmbeddedChannel(new ChannelInboundHandler() { }); ScheduledFuture future = ch.eventLoop().schedule(() -> { }, 1, TimeUnit.DAYS); ch.finish(); assertTrue(future.isCancelled()); @@ -195,7 +195,7 @@ public class EmbeddedChannelTest { private static void testFireChannelInactiveAndUnregistered(Action action) throws InterruptedException { final CountDownLatch latch = new CountDownLatch(3); - EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandlerAdapter() { + EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandler() { @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { latch.countDown(); @@ -321,7 +321,7 @@ public class EmbeddedChannelTest { @Test public void testWriteLater() { - EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandlerAdapter() { + EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandler() { @Override public void write(final ChannelHandlerContext ctx, final Object msg, final ChannelPromise promise) throws Exception { @@ -339,7 +339,7 @@ public class EmbeddedChannelTest { @Test public void testWriteScheduled() throws InterruptedException { final int delay = 500; - EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandlerAdapter() { + EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandler() { @Override public void write(final ChannelHandlerContext ctx, final Object msg, final ChannelPromise promise) throws Exception { @@ -360,7 +360,7 @@ public class EmbeddedChannelTest { @Test public void testFlushInbound() throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); - EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandlerAdapter() { + EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandler() { @Override public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { latch.countDown(); @@ -379,7 +379,7 @@ public class EmbeddedChannelTest { final CountDownLatch latch = new CountDownLatch(1); final AtomicInteger flushCount = new AtomicInteger(0); - EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandlerAdapter() { + EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { ReferenceCountUtil.release(msg); @@ -408,7 +408,7 @@ public class EmbeddedChannelTest { @Test public void testFlushOutbound() throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); - EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandlerAdapter() { + EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandler() { @Override public void flush(ChannelHandlerContext ctx) throws Exception { latch.countDown(); @@ -427,7 +427,7 @@ public class EmbeddedChannelTest { final CountDownLatch latch = new CountDownLatch(1); final AtomicInteger flushCount = new AtomicInteger(0); - EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandlerAdapter() { + EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandler() { @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { ctx.write(msg, promise); @@ -516,7 +516,7 @@ public class EmbeddedChannelTest { @Test(timeout = 5000) public void testChannelInactiveFired() throws InterruptedException { final AtomicBoolean inactive = new AtomicBoolean(); - EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandlerAdapter() { + EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { ctx.close(); @@ -540,7 +540,7 @@ public class EmbeddedChannelTest { } } - private static final class EventOutboundHandler extends ChannelOutboundHandlerAdapter { + private static final class EventOutboundHandler implements ChannelOutboundHandler { static final Integer DISCONNECT = 0; static final Integer CLOSE = 1; diff --git a/transport/src/test/java/io/netty/channel/group/DefaultChannelGroupTest.java b/transport/src/test/java/io/netty/channel/group/DefaultChannelGroupTest.java index 49ebb1f206..ad4e569172 100644 --- a/transport/src/test/java/io/netty/channel/group/DefaultChannelGroupTest.java +++ b/transport/src/test/java/io/netty/channel/group/DefaultChannelGroupTest.java @@ -18,7 +18,7 @@ package io.netty.channel.group; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.EventLoopGroup; import io.netty.channel.MultithreadEventLoopGroup; import io.netty.channel.nio.NioHandler; @@ -38,7 +38,7 @@ public class DefaultChannelGroupTest { ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup); - b.childHandler(new ChannelInboundHandlerAdapter() { + b.childHandler(new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) { allChannels.add(ctx.channel()); diff --git a/transport/src/test/java/io/netty/channel/local/LocalChannelTest.java b/transport/src/test/java/io/netty/channel/local/LocalChannelTest.java index aa0900fcaa..65a870e392 100644 --- a/transport/src/test/java/io/netty/channel/local/LocalChannelTest.java +++ b/transport/src/test/java/io/netty/channel/local/LocalChannelTest.java @@ -24,7 +24,7 @@ import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelOption; import io.netty.channel.ChannelPromise; @@ -339,20 +339,20 @@ public class LocalChannelTest { sb.group(group2) .channel(LocalServerChannel.class) - .childHandler(new ChannelInboundHandlerAdapter() { + .childHandler(new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg.equals(data)) { ReferenceCountUtil.safeRelease(msg); messageLatch.countDown(); } else { - super.channelRead(ctx, msg); + ctx.fireChannelRead(msg); } } @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { messageLatch.countDown(); - super.channelInactive(ctx); + ctx.fireChannelInactive(); } }); @@ -394,7 +394,7 @@ public class LocalChannelTest { try { cb.group(sharedGroup) .channel(LocalChannel.class) - .handler(new ChannelInboundHandlerAdapter() { + .handler(new ChannelInboundHandler() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { ctx.writeAndFlush(data.retainedDuplicate()); @@ -406,14 +406,14 @@ public class LocalChannelTest { ReferenceCountUtil.safeRelease(msg); messageLatch.countDown(); } else { - super.channelRead(ctx, msg); + ctx.fireChannelRead(msg); } } }); sb.group(sharedGroup) .channel(LocalServerChannel.class) - .childHandler(new ChannelInboundHandlerAdapter() { + .childHandler(new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (data.equals(msg)) { @@ -421,14 +421,14 @@ public class LocalChannelTest { ctx.writeAndFlush(data); ctx.close(); } else { - super.channelRead(ctx, msg); + ctx.fireChannelRead(msg); } } @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { messageLatch.countDown(); - super.channelInactive(ctx); + ctx.fireChannelInactive(); } }); @@ -466,7 +466,7 @@ public class LocalChannelTest { sb.group(group2) .channel(LocalServerChannel.class) - .childHandler(new ChannelInboundHandlerAdapter() { + .childHandler(new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { final long count = messageLatch.getCount(); @@ -474,7 +474,7 @@ public class LocalChannelTest { ReferenceCountUtil.safeRelease(msg); messageLatch.countDown(); } else { - super.channelRead(ctx, msg); + ctx.fireChannelRead(msg); } } }); @@ -520,14 +520,14 @@ public class LocalChannelTest { cb.group(group1) .channel(LocalChannel.class) - .handler(new ChannelInboundHandlerAdapter() { + .handler(new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (data2.equals(msg)) { ReferenceCountUtil.safeRelease(msg); messageLatch.countDown(); } else { - super.channelRead(ctx, msg); + ctx.fireChannelRead(msg); } } }); @@ -537,14 +537,14 @@ public class LocalChannelTest { .childHandler(new ChannelInitializer() { @Override public void initChannel(LocalChannel ch) throws Exception { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (data.equals(msg)) { ReferenceCountUtil.safeRelease(msg); messageLatch.countDown(); } else { - super.channelRead(ctx, msg); + ctx.fireChannelRead(msg); } } }); @@ -596,14 +596,14 @@ public class LocalChannelTest { try { cb.group(sharedGroup) .channel(LocalChannel.class) - .handler(new ChannelInboundHandlerAdapter() { + .handler(new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (data2.equals(msg) && messageLatch.getCount() == 1) { ReferenceCountUtil.safeRelease(msg); messageLatch.countDown(); } else { - super.channelRead(ctx, msg); + ctx.fireChannelRead(msg); } } }); @@ -613,14 +613,14 @@ public class LocalChannelTest { .childHandler(new ChannelInitializer() { @Override public void initChannel(LocalChannel ch) throws Exception { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (data.equals(msg) && messageLatch.getCount() == 2) { ReferenceCountUtil.safeRelease(msg); messageLatch.countDown(); } else { - super.channelRead(ctx, msg); + ctx.fireChannelRead(msg); } } }); @@ -685,14 +685,14 @@ public class LocalChannelTest { .childHandler(new ChannelInitializer() { @Override public void initChannel(LocalChannel ch) throws Exception { - ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { + ch.pipeline().addLast(new ChannelInboundHandler() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (data.equals(msg)) { ReferenceCountUtil.safeRelease(msg); serverMessageLatch.countDown(); } else { - super.channelRead(ctx, msg); + ctx.fireChannelRead(msg); } } }); @@ -769,7 +769,7 @@ public class LocalChannelTest { cb.group(group1) .channel(LocalChannel.class) - .handler(new ChannelInboundHandlerAdapter()); + .handler(new ChannelInboundHandler() { }); sb.group(group2) .channel(LocalServerChannel.class) @@ -839,7 +839,7 @@ public class LocalChannelTest { } } - static class TestHandler extends ChannelInboundHandlerAdapter { + static class TestHandler implements ChannelInboundHandler { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { logger.info(String.format("Received message: %s", msg)); @@ -934,7 +934,7 @@ public class LocalChannelTest { cb.group(serverGroup) .channel(LocalChannel.class) .option(ChannelOption.AUTO_READ, false) - .handler(new ChannelInboundHandlerAdapter() { + .handler(new ChannelInboundHandler() { @Override public void channelActive(final ChannelHandlerContext ctx) throws Exception { @@ -950,7 +950,7 @@ public class LocalChannelTest { sb.group(clientGroup) .channel(LocalServerChannel.class) .childOption(ChannelOption.AUTO_READ, false) - .childHandler(new ChannelInboundHandlerAdapter() { + .childHandler(new ChannelInboundHandler() { @Override public void channelActive(final ChannelHandlerContext ctx) throws Exception { ctx.read(); @@ -1012,7 +1012,7 @@ public class LocalChannelTest { .handler(new ChannelReadHandler(countDownLatch, autoRead)); sb.group(clientGroup) .channel(LocalServerChannel.class) - .childHandler(new ChannelInboundHandlerAdapter() { + .childHandler(new ChannelInboundHandler() { @Override public void channelActive(final ChannelHandlerContext ctx) { for (int i = 0; i < 10; i++) { @@ -1102,7 +1102,7 @@ public class LocalChannelTest { } } - private static final class ChannelReadHandler extends ChannelInboundHandlerAdapter { + private static final class ChannelReadHandler implements ChannelInboundHandler { private final CountDownLatch latch; private final boolean autoRead; diff --git a/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest2.java b/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest2.java index 28c87c7226..08e375f2b2 100644 --- a/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest2.java +++ b/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest2.java @@ -21,7 +21,7 @@ import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandler.Sharable; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.MultithreadEventLoopGroup; import io.netty.util.ReferenceCountUtil; import org.junit.Test; @@ -90,7 +90,7 @@ public class LocalTransportThreadModelTest2 { } @Sharable - static class LocalHandler extends ChannelInboundHandlerAdapter { + static class LocalHandler implements ChannelInboundHandler { private final String name; public volatile ChannelFuture lastWriteFuture; diff --git a/transport/src/test/java/io/netty/channel/socket/nio/NioDatagramChannelTest.java b/transport/src/test/java/io/netty/channel/socket/nio/NioDatagramChannelTest.java index 36460ac0bf..e57e554281 100644 --- a/transport/src/test/java/io/netty/channel/socket/nio/NioDatagramChannelTest.java +++ b/transport/src/test/java/io/netty/channel/socket/nio/NioDatagramChannelTest.java @@ -17,7 +17,7 @@ package io.netty.channel.socket.nio; import io.netty.bootstrap.Bootstrap; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInboundHandler; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; import io.netty.channel.MultithreadEventLoopGroup; @@ -49,7 +49,7 @@ public class NioDatagramChannelTest extends AbstractNioChannelTest