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.
This commit is contained in:
Norman Maurer 2019-03-13 09:46:10 +01:00 committed by GitHub
parent 2720a40a20
commit 42742e233f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
134 changed files with 563 additions and 862 deletions

View File

@ -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;
* </pre>
* </blockquote>
*/
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);
}
}

View File

@ -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);
}
}

View File

@ -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());

View File

@ -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) {

View File

@ -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;

View File

@ -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() {

View File

@ -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<FullHttpRequest> 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, "/")));

View File

@ -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);

View File

@ -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, "/")));

View File

@ -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() { });
}
}

View File

@ -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

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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();

View File

@ -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 { }
}

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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);

View File

@ -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();
}
}

View File

@ -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<Http2StreamChannel> 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<String> 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.

View File

@ -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 { }
}

View File

@ -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) {

View File

@ -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) {

View File

@ -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();

View File

@ -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 <tt>out</tt> {@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 {

View File

@ -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;
* }
* </pre>
*/
public abstract class MessageToByteEncoder<I> extends ChannelOutboundHandlerAdapter {
public abstract class MessageToByteEncoder<I> extends ChannelHandlerAdapter implements ChannelOutboundHandler {
private final TypeParameterMatcher matcher;
private final boolean preferDirect;

View File

@ -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<I> extends ChannelInboundHandlerAdapter {
public abstract class MessageToMessageDecoder<I> extends ChannelHandlerAdapter implements ChannelInboundHandler {
private final TypeParameterMatcher matcher;

View File

@ -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<I> extends ChannelOutboundHandlerAdapter {
public abstract class MessageToMessageEncoder<I> extends ChannelHandlerAdapter implements ChannelOutboundHandler {
private final TypeParameterMatcher matcher;

View File

@ -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) {

View File

@ -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

View File

@ -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) {

View File

@ -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);

View File

@ -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;

View File

@ -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) {

View File

@ -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<SocketChannel> {
/**
* 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<SocketChannel> {
/**
* 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);

View File

@ -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<SocketChannel> {
/**
* 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);

View File

@ -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<SocketChannel> {
/**
* 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);

View File

@ -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<SocketChannel> {
/**
* 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);

View File

@ -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) {

View File

@ -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<Integer> firstMessage;

View File

@ -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) {

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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) {

View File

@ -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<Channel> promise;

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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<T extends SocketAddress> extends ChannelInboundHandlerAdapter {
public abstract class AbstractRemoteAddressFilter<T extends SocketAddress> implements ChannelInboundHandler {
@Override
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {

View File

@ -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;
* }
* </pre>
*/
public abstract class ApplicationProtocolNegotiationHandler extends ChannelInboundHandlerAdapter {
public abstract class ApplicationProtocolNegotiationHandler implements ChannelInboundHandler {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(ApplicationProtocolNegotiationHandler.class);

View File

@ -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(...)");

View File

@ -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;

View File

@ -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<Channel> 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();

View File

@ -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);

View File

@ -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);
}
}
});

View File

@ -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 {

View File

@ -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) {

View File

@ -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) {

View File

@ -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<SslHandshakeCompletionEvent> 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<SniCompletionEvent> 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) {

View File

@ -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

View File

@ -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<SslCompletionEvent> 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<Channel>() {
@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 }));

View File

@ -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<Throwable> 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<Throwable> 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 {

View File

@ -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

View File

@ -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<Object> 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<Object> 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<Object> events = new ArrayList<>();
ChannelInboundHandlerAdapter handler = new ChannelInboundHandlerAdapter() {
ChannelInboundHandler handler = new ChannelInboundHandler() {
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
events.add(evt);

View File

@ -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);

View File

@ -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" })

View File

@ -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<Channel> 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());
}

View File

@ -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;

View File

@ -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<SocketChannel> {
/**
* 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);

View File

@ -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<Channel>() {
@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<Channel>() {
@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<Channel>() {
@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<Channel>() {
@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) {

View File

@ -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<Throwable> promise = ImmediateEventExecutor.INSTANCE.newPromise();
cb.handler(new ChannelInboundHandlerAdapter() {
cb.handler(new ChannelInboundHandler() {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
promise.trySuccess(cause);

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

@ -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();

View File

@ -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<Channel>() {
@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) {

View File

@ -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<InetSocketAddress> 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);

View File

@ -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<Error> 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(

View File

@ -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<Channel>() {
@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();

View File

@ -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();

View File

@ -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)}.

View File

@ -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();

View File

@ -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<Channel>() {
@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<Channel>() {
@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<Channel>() {
@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<Channel>() {
@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<Channel>() {
@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<Channel>() {
@Override
protected void initChannel(Channel ch) throws Exception {
ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
ch.pipeline().addLast(new ChannelInboundHandler() {
private int bytesRead;
@Override

View File

@ -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();

View File

@ -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<Throwable> exception = new AtomicReference<>();

View File

@ -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);

View File

@ -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<Channel>() {
@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<Channel>() {
@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);

View File

@ -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();

View File

@ -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();

View File

@ -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<Object> 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;

View File

@ -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) {

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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 {

View File

@ -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();

View File

@ -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;

View File

@ -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 {

Some files were not shown because too many files have changed in this diff Show More