Rename SimpleChannelInboundHandler.channelRead0() to messageReceived() (#8819)

Motivation

Per javadoc in 4.1.x SimpleChannelInboundHandler:

"Please keep in mind that channelRead0(ChannelHandlerContext, I) will be
renamed to messageReceived(ChannelHandlerContext, I) in 5.0."

Modifications

Rename aforementioned method and all references/overrides.

Result

Method is renamed.
This commit is contained in:
Nick Hill 2019-10-31 23:23:07 -07:00 committed by Norman Maurer
parent e77b9104d7
commit 7df012884f
83 changed files with 116 additions and 124 deletions

View File

@ -427,7 +427,7 @@ public abstract class WebSocketClientHandshaker {
p.addAfter(ctx.name(), aggregatorName, new HttpObjectAggregator(8192)); p.addAfter(ctx.name(), aggregatorName, new HttpObjectAggregator(8192));
p.addAfter(aggregatorName, "handshaker", new SimpleChannelInboundHandler<FullHttpResponse>() { p.addAfter(aggregatorName, "handshaker", new SimpleChannelInboundHandler<FullHttpResponse>() {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, FullHttpResponse msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, FullHttpResponse msg) throws Exception {
// Remove ourself and do the actual handshake // Remove ourself and do the actual handshake
ctx.pipeline().remove(this); ctx.pipeline().remove(this);
try { try {

View File

@ -291,7 +291,7 @@ public abstract class WebSocketServerHandshaker {
p.addAfter(ctx.name(), aggregatorName, new HttpObjectAggregator(8192)); p.addAfter(ctx.name(), aggregatorName, new HttpObjectAggregator(8192));
p.addAfter(aggregatorName, "handshaker", new SimpleChannelInboundHandler<FullHttpRequest>() { p.addAfter(aggregatorName, "handshaker", new SimpleChannelInboundHandler<FullHttpRequest>() {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, FullHttpRequest msg) throws Exception {
// Remove ourself and do the actual handshake // Remove ourself and do the actual handshake
ctx.pipeline().remove(this); ctx.pipeline().remove(this);
handshake(channel, msg, responseHeaders, promise); handshake(channel, msg, responseHeaders, promise);

View File

@ -136,7 +136,7 @@ public class HttpClientCodecTest {
ch.pipeline().addLast(new HttpObjectAggregator(4096)); ch.pipeline().addLast(new HttpObjectAggregator(4096));
ch.pipeline().addLast(new SimpleChannelInboundHandler<FullHttpRequest>() { ch.pipeline().addLast(new SimpleChannelInboundHandler<FullHttpRequest>() {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest msg) { protected void messageReceived(ChannelHandlerContext ctx, FullHttpRequest msg) {
// This is just a simple demo...don't block in IO // This is just a simple demo...don't block in IO
assertTrue(ctx.channel() instanceof SocketChannel); assertTrue(ctx.channel() instanceof SocketChannel);
final SocketChannel sChannel = (SocketChannel) ctx.channel(); final SocketChannel sChannel = (SocketChannel) ctx.channel();
@ -174,7 +174,7 @@ public class HttpClientCodecTest {
ch.pipeline().addLast(new HttpObjectAggregator(4096)); ch.pipeline().addLast(new HttpObjectAggregator(4096));
ch.pipeline().addLast(new SimpleChannelInboundHandler<FullHttpResponse>() { ch.pipeline().addLast(new SimpleChannelInboundHandler<FullHttpResponse>() {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, FullHttpResponse msg) { protected void messageReceived(ChannelHandlerContext ctx, FullHttpResponse msg) {
responseReceivedLatch.countDown(); responseReceivedLatch.countDown();
} }
}); });

View File

@ -542,7 +542,7 @@ public class CorsHandlerTest {
private static class EchoHandler extends SimpleChannelInboundHandler<Object> { private static class EchoHandler extends SimpleChannelInboundHandler<Object> {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
ctx.writeAndFlush(new DefaultFullHttpResponse(HTTP_1_1, OK, true, true)); ctx.writeAndFlush(new DefaultFullHttpResponse(HTTP_1_1, OK, true, true));
} }
} }

View File

@ -294,7 +294,7 @@ public abstract class WebSocketClientHandshakerTest {
EmbeddedChannel ch = new EmbeddedChannel(new HttpObjectAggregator(Integer.MAX_VALUE), EmbeddedChannel ch = new EmbeddedChannel(new HttpObjectAggregator(Integer.MAX_VALUE),
new SimpleChannelInboundHandler<FullHttpResponse>() { new SimpleChannelInboundHandler<FullHttpResponse>() {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, FullHttpResponse msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, FullHttpResponse msg) throws Exception {
handshaker.finishHandshake(ctx.channel(), msg); handshaker.finishHandshake(ctx.channel(), msg);
ctx.pipeline().remove(this); ctx.pipeline().remove(this);
} }

View File

@ -88,7 +88,7 @@ public class WebSocketHandshakeHandOverTest {
} }
} }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
} }
}); });
@ -100,7 +100,7 @@ public class WebSocketHandshakeHandOverTest {
} }
} }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof TextWebSocketFrame) { if (msg instanceof TextWebSocketFrame) {
clientReceivedMessage = true; clientReceivedMessage = true;
} }
@ -136,7 +136,7 @@ public class WebSocketHandshakeHandOverTest {
} }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
} }
}); });
@ -151,7 +151,7 @@ public class WebSocketHandshakeHandOverTest {
} }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof TextWebSocketFrame) { if (msg instanceof TextWebSocketFrame) {
clientReceivedMessage = true; clientReceivedMessage = true;
} }
@ -193,7 +193,7 @@ public class WebSocketHandshakeHandOverTest {
new CloseNoOpServerProtocolHandler("/test"), new CloseNoOpServerProtocolHandler("/test"),
new SimpleChannelInboundHandler<Object>() { new SimpleChannelInboundHandler<Object>() {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
} }
}); });
@ -211,7 +211,7 @@ public class WebSocketHandshakeHandOverTest {
} }
} }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
} }
}); });

View File

@ -793,7 +793,7 @@ public class InboundHttp2ToHttpAdapterTest {
} }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
listener.messageReceived(msg); listener.messageReceived(msg);
latch.countDown(); latch.countDown();
latch2.countDown(); latch2.countDown();
@ -811,7 +811,7 @@ public class InboundHttp2ToHttpAdapterTest {
} }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, Http2Settings settings) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, Http2Settings settings) throws Exception {
listener.messageReceived(settings); listener.messageReceived(settings);
latch.countDown(); latch.countDown();
} }

View File

@ -46,7 +46,7 @@ public class DiscardClientHandler extends SimpleChannelInboundHandler<Object> {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
// Server is supposed to send nothing, but if it sends something, discard it. // Server is supposed to send nothing, but if it sends something, discard it.
} }

View File

@ -24,7 +24,7 @@ import io.netty.channel.SimpleChannelInboundHandler;
public class DiscardServerHandler extends SimpleChannelInboundHandler<Object> { public class DiscardServerHandler extends SimpleChannelInboundHandler<Object> {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
// discard // discard
} }

View File

@ -62,7 +62,7 @@ public class FactorialClientHandler extends SimpleChannelInboundHandler<BigInteg
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, final BigInteger msg) { public void messageReceived(ChannelHandlerContext ctx, final BigInteger msg) {
receivedMessages ++; receivedMessages ++;
if (receivedMessages == FactorialClient.COUNT) { if (receivedMessages == FactorialClient.COUNT) {
// Offer the answer after closing the connection. // Offer the answer after closing the connection.

View File

@ -33,7 +33,7 @@ public class FactorialServerHandler extends SimpleChannelInboundHandler<BigInteg
private BigInteger factorial = new BigInteger("1"); private BigInteger factorial = new BigInteger("1");
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, BigInteger msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, BigInteger msg) throws Exception {
// Calculate the cumulative factorial and send it to the client. // Calculate the cumulative factorial and send it to the client.
lastMultiplier = msg; lastMultiplier = msg;
factorial = factorial.multiply(msg); factorial = factorial.multiply(msg);

View File

@ -33,7 +33,7 @@ public class FileServerHandler extends SimpleChannelInboundHandler<String> {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception {
RandomAccessFile raf = null; RandomAccessFile raf = null;
long length = -1; long length = -1;
try { try {

View File

@ -30,7 +30,7 @@ import io.netty.handler.codec.http.HttpVersion;
*/ */
public class OkResponseHandler extends SimpleChannelInboundHandler<Object> { public class OkResponseHandler extends SimpleChannelInboundHandler<Object> {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) { public void messageReceived(ChannelHandlerContext ctx, Object msg) {
final FullHttpResponse response = new DefaultFullHttpResponse( final FullHttpResponse response = new DefaultFullHttpResponse(
HttpVersion.HTTP_1_1, HttpResponseStatus.OK, Unpooled.EMPTY_BUFFER); HttpVersion.HTTP_1_1, HttpResponseStatus.OK, Unpooled.EMPTY_BUFFER);
response.headers().set("custom-response-header", "Some value"); response.headers().set("custom-response-header", "Some value");

View File

@ -113,7 +113,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelInboundHandler<Ful
private FullHttpRequest request; private FullHttpRequest request;
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception { public void messageReceived(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception {
this.request = request; this.request = request;
if (!request.decoderResult().isSuccess()) { if (!request.decoderResult().isSuccess()) {
sendError(ctx, BAD_REQUEST); sendError(ctx, BAD_REQUEST);

View File

@ -43,7 +43,7 @@ public class HttpHelloWorldServerHandler extends SimpleChannelInboundHandler<Htt
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) { public void messageReceived(ChannelHandlerContext ctx, HttpObject msg) {
if (msg instanceof HttpRequest) { if (msg instanceof HttpRequest) {
HttpRequest req = (HttpRequest) msg; HttpRequest req = (HttpRequest) msg;

View File

@ -27,7 +27,7 @@ import io.netty.util.CharsetUtil;
public class HttpSnoopClientHandler extends SimpleChannelInboundHandler<HttpObject> { public class HttpSnoopClientHandler extends SimpleChannelInboundHandler<HttpObject> {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) { public void messageReceived(ChannelHandlerContext ctx, HttpObject msg) {
if (msg instanceof HttpResponse) { if (msg instanceof HttpResponse) {
HttpResponse response = (HttpResponse) msg; HttpResponse response = (HttpResponse) msg;

View File

@ -57,7 +57,7 @@ public class HttpSnoopServerHandler extends SimpleChannelInboundHandler<Object>
} }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) { protected void messageReceived(ChannelHandlerContext ctx, Object msg) {
if (msg instanceof HttpRequest) { if (msg instanceof HttpRequest) {
HttpRequest request = this.request = (HttpRequest) msg; HttpRequest request = this.request = (HttpRequest) msg;

View File

@ -32,7 +32,7 @@ public class HttpUploadClientHandler extends SimpleChannelInboundHandler<HttpObj
private boolean readingChunks; private boolean readingChunks;
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) { public void messageReceived(ChannelHandlerContext ctx, HttpObject msg) {
if (msg instanceof HttpResponse) { if (msg instanceof HttpResponse) {
HttpResponse response = (HttpResponse) msg; HttpResponse response = (HttpResponse) msg;

View File

@ -96,7 +96,7 @@ public class HttpUploadServerHandler extends SimpleChannelInboundHandler<HttpObj
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
if (msg instanceof HttpRequest) { if (msg instanceof HttpRequest) {
HttpRequest request = this.request = (HttpRequest) msg; HttpRequest request = this.request = (HttpRequest) msg;
URI uri = new URI(request.uri()); URI uri = new URI(request.uri());

View File

@ -56,7 +56,7 @@ public class WebSocketServerHandler extends SimpleChannelInboundHandler<Object>
private WebSocketServerHandshaker handshaker; private WebSocketServerHandshaker handshaker;
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) { public void messageReceived(ChannelHandlerContext ctx, Object msg) {
if (msg instanceof FullHttpRequest) { if (msg instanceof FullHttpRequest) {
handleHttpRequest(ctx, (FullHttpRequest) msg); handleHttpRequest(ctx, (FullHttpRequest) msg);
} else if (msg instanceof WebSocketFrame) { } else if (msg instanceof WebSocketFrame) {

View File

@ -80,7 +80,7 @@ public class WebSocketClientHandler extends SimpleChannelInboundHandler<Object>
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
Channel ch = ctx.channel(); Channel ch = ctx.channel();
if (!handshaker.isHandshakeComplete()) { if (!handshaker.isHandshakeComplete()) {
try { try {

View File

@ -28,7 +28,7 @@ import io.netty.handler.codec.http.websocketx.WebSocketFrame;
public class WebSocketFrameHandler extends SimpleChannelInboundHandler<WebSocketFrame> { public class WebSocketFrameHandler extends SimpleChannelInboundHandler<WebSocketFrame> {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, WebSocketFrame frame) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, WebSocketFrame frame) throws Exception {
// ping and pong frames already handled // ping and pong frames already handled
if (frame instanceof TextWebSocketFrame) { if (frame instanceof TextWebSocketFrame) {

View File

@ -54,7 +54,7 @@ public class WebSocketIndexPageHandler extends SimpleChannelInboundHandler<FullH
} }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest req) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, FullHttpRequest req) throws Exception {
// Handle a bad request. // Handle a bad request.
if (!req.decoderResult().isSuccess()) { if (!req.decoderResult().isSuccess()) {
sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, BAD_REQUEST, Unpooled.EMPTY_BUFFER)); sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, BAD_REQUEST, Unpooled.EMPTY_BUFFER));

View File

@ -54,7 +54,7 @@ public class Http2SettingsHandler extends SimpleChannelInboundHandler<Http2Setti
} }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, Http2Settings msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, Http2Settings msg) throws Exception {
promise.setSuccess(); promise.setSuccess();
// Only care about the first settings message // Only care about the first settings message

View File

@ -87,7 +87,7 @@ public class HttpResponseHandler extends SimpleChannelInboundHandler<FullHttpRes
} }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, FullHttpResponse msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, FullHttpResponse msg) throws Exception {
Integer streamId = msg.headers().getInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text()); Integer streamId = msg.headers().getInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text());
if (streamId == null) { if (streamId == null) {
System.err.println("HttpResponseHandler unexpected message received: " + msg); System.err.println("HttpResponseHandler unexpected message received: " + msg);

View File

@ -92,7 +92,7 @@ public class Http2ServerInitializer extends ChannelInitializer<SocketChannel> {
p.addLast(new HttpServerUpgradeHandler(sourceCodec, upgradeCodecFactory)); p.addLast(new HttpServerUpgradeHandler(sourceCodec, upgradeCodecFactory));
p.addLast(new SimpleChannelInboundHandler<HttpMessage>() { p.addLast(new SimpleChannelInboundHandler<HttpMessage>() {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, HttpMessage msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, HttpMessage msg) throws Exception {
// If this handler is hit then no upgrade has been attempted and the client is just talking HTTP. // If this handler is hit then no upgrade has been attempted and the client is just talking HTTP.
System.err.println("Directly talking: " + msg.protocolVersion() + " (no upgrade was attempted)"); System.err.println("Directly talking: " + msg.protocolVersion() + " (no upgrade was attempted)");
ChannelPipeline pipeline = ctx.pipeline(); ChannelPipeline pipeline = ctx.pipeline();

View File

@ -94,7 +94,7 @@ public class Http2ServerInitializer extends ChannelInitializer<SocketChannel> {
p.addLast(new HttpServerUpgradeHandler(sourceCodec, upgradeCodecFactory)); p.addLast(new HttpServerUpgradeHandler(sourceCodec, upgradeCodecFactory));
p.addLast(new SimpleChannelInboundHandler<HttpMessage>() { p.addLast(new SimpleChannelInboundHandler<HttpMessage>() {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, HttpMessage msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, HttpMessage msg) throws Exception {
// If this handler is hit then no upgrade has been attempted and the client is just talking HTTP. // If this handler is hit then no upgrade has been attempted and the client is just talking HTTP.
System.err.println("Directly talking: " + msg.protocolVersion() + " (no upgrade was attempted)"); System.err.println("Directly talking: " + msg.protocolVersion() + " (no upgrade was attempted)");
ChannelPipeline pipeline = ctx.pipeline(); ChannelPipeline pipeline = ctx.pipeline();

View File

@ -48,7 +48,7 @@ public class HelloWorldHttp1Handler extends SimpleChannelInboundHandler<FullHttp
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, FullHttpRequest req) throws Exception { public void messageReceived(ChannelHandlerContext ctx, FullHttpRequest req) throws Exception {
if (HttpUtil.is100ContinueExpected(req)) { if (HttpUtil.is100ContinueExpected(req)) {
ctx.write(new DefaultFullHttpResponse(HTTP_1_1, CONTINUE, Unpooled.EMPTY_BUFFER)); ctx.write(new DefaultFullHttpResponse(HTTP_1_1, CONTINUE, Unpooled.EMPTY_BUFFER));
} }

View File

@ -93,7 +93,7 @@ public class Http2ServerInitializer extends ChannelInitializer<SocketChannel> {
p.addLast(cleartextHttp2ServerUpgradeHandler); p.addLast(cleartextHttp2ServerUpgradeHandler);
p.addLast(new SimpleChannelInboundHandler<HttpMessage>() { p.addLast(new SimpleChannelInboundHandler<HttpMessage>() {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, HttpMessage msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, HttpMessage msg) throws Exception {
// If this handler is hit then no upgrade has been attempted and the client is just talking HTTP. // If this handler is hit then no upgrade has been attempted and the client is just talking HTTP.
System.err.println("Directly talking: " + msg.protocolVersion() + " (no upgrade was attempted)"); System.err.println("Directly talking: " + msg.protocolVersion() + " (no upgrade was attempted)");
ChannelPipeline pipeline = ctx.pipeline(); ChannelPipeline pipeline = ctx.pipeline();

View File

@ -46,7 +46,7 @@ public final class FallbackRequestHandler extends SimpleChannelInboundHandler<Ht
+ ")</h2></body></html>", UTF_8)).asReadOnly(); + ")</h2></body></html>", UTF_8)).asReadOnly();
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, HttpRequest req) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, HttpRequest req) throws Exception {
if (HttpUtil.is100ContinueExpected(req)) { if (HttpUtil.is100ContinueExpected(req)) {
ctx.write(new DefaultFullHttpResponse(HTTP_1_1, CONTINUE, EMPTY_BUFFER)); ctx.write(new DefaultFullHttpResponse(HTTP_1_1, CONTINUE, EMPTY_BUFFER));
} }

View File

@ -40,11 +40,11 @@ import java.util.concurrent.TimeUnit;
public final class Http1RequestHandler extends Http2RequestHandler { public final class Http1RequestHandler extends Http2RequestHandler {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception {
if (HttpUtil.is100ContinueExpected(request)) { if (HttpUtil.is100ContinueExpected(request)) {
ctx.write(new DefaultFullHttpResponse(HTTP_1_1, CONTINUE, Unpooled.EMPTY_BUFFER)); ctx.write(new DefaultFullHttpResponse(HTTP_1_1, CONTINUE, Unpooled.EMPTY_BUFFER));
} }
super.channelRead0(ctx, request); super.messageReceived(ctx, request);
} }
@Override @Override

View File

@ -52,7 +52,7 @@ public class Http2RequestHandler extends SimpleChannelInboundHandler<FullHttpReq
private static final String IMAGE_COORDINATE_X = "x"; private static final String IMAGE_COORDINATE_X = "x";
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception {
QueryStringDecoder queryString = new QueryStringDecoder(request.uri()); QueryStringDecoder queryString = new QueryStringDecoder(request.uri());
String streamId = streamId(request); String streamId = streamId(request);
int latency = toInt(firstValue(queryString, LATENCY_FIELD_NAME), 0); int latency = toInt(firstValue(queryString, LATENCY_FIELD_NAME), 0);

View File

@ -21,7 +21,7 @@ import io.netty.channel.SimpleChannelInboundHandler;
public class LocalEchoClientHandler extends SimpleChannelInboundHandler<Object> { public class LocalEchoClientHandler extends SimpleChannelInboundHandler<Object> {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
// Print as received // Print as received
System.out.println(msg); System.out.println(msg);
} }

View File

@ -23,7 +23,7 @@ import io.netty.util.CharsetUtil;
public class QuoteOfTheMomentClientHandler extends SimpleChannelInboundHandler<DatagramPacket> { public class QuoteOfTheMomentClientHandler extends SimpleChannelInboundHandler<DatagramPacket> {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
String response = msg.content().toString(CharsetUtil.UTF_8); String response = msg.content().toString(CharsetUtil.UTF_8);
if (response.startsWith("QOTM: ")) { if (response.startsWith("QOTM: ")) {
System.out.println("Quote of the Moment: " + response.substring(6)); System.out.println("Quote of the Moment: " + response.substring(6));

View File

@ -44,7 +44,7 @@ public class QuoteOfTheMomentServerHandler extends SimpleChannelInboundHandler<D
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, DatagramPacket packet) throws Exception { public void messageReceived(ChannelHandlerContext ctx, DatagramPacket packet) throws Exception {
System.err.println(packet); System.err.println(packet);
if ("QOTM?".equals(packet.content().toString(CharsetUtil.UTF_8))) { if ("QOTM?".equals(packet.content().toString(CharsetUtil.UTF_8))) {
ctx.write(new DatagramPacket( ctx.write(new DatagramPacket(

View File

@ -24,7 +24,7 @@ import io.netty.channel.SimpleChannelInboundHandler;
public class SecureChatClientHandler extends SimpleChannelInboundHandler<String> { public class SecureChatClientHandler extends SimpleChannelInboundHandler<String> {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception {
System.err.println(msg); System.err.println(msg);
} }

View File

@ -52,7 +52,7 @@ public class SecureChatServerHandler extends SimpleChannelInboundHandler<String>
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception {
// Send the received message to all channels but the current one. // Send the received message to all channels but the current one.
for (Channel c: channels) { for (Channel c: channels) {
if (c != ctx.channel()) { if (c != ctx.channel()) {

View File

@ -41,7 +41,7 @@ public final class SocksServerConnectHandler extends SimpleChannelInboundHandler
private final Bootstrap b = new Bootstrap(); private final Bootstrap b = new Bootstrap();
@Override @Override
public void channelRead0(final ChannelHandlerContext ctx, final SocksMessage message) throws Exception { public void messageReceived(final ChannelHandlerContext ctx, final SocksMessage message) throws Exception {
if (message instanceof Socks4CommandRequest) { if (message instanceof Socks4CommandRequest) {
final Socks4CommandRequest request = (Socks4CommandRequest) message; final Socks4CommandRequest request = (Socks4CommandRequest) message;
Promise<Channel> promise = ctx.executor().newPromise(); Promise<Channel> promise = ctx.executor().newPromise();

View File

@ -39,7 +39,7 @@ public final class SocksServerHandler extends SimpleChannelInboundHandler<SocksM
private SocksServerHandler() { } private SocksServerHandler() { }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, SocksMessage socksRequest) throws Exception { public void messageReceived(ChannelHandlerContext ctx, SocksMessage socksRequest) throws Exception {
switch (socksRequest.version()) { switch (socksRequest.version()) {
case SOCKS4a: case SOCKS4a:
Socks4CommandRequest socksV4CmdRequest = (Socks4CommandRequest) socksRequest; Socks4CommandRequest socksV4CmdRequest = (Socks4CommandRequest) socksRequest;

View File

@ -48,7 +48,7 @@ public class StompClientHandler extends SimpleChannelInboundHandler<StompFrame>
} }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, StompFrame frame) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, StompFrame frame) throws Exception {
String subscrReceiptId = "001"; String subscrReceiptId = "001";
String disconReceiptId = "002"; String disconReceiptId = "002";
switch (frame.command()) { switch (frame.command()) {

View File

@ -26,7 +26,7 @@ import io.netty.channel.SimpleChannelInboundHandler;
public class TelnetClientHandler extends SimpleChannelInboundHandler<String> { public class TelnetClientHandler extends SimpleChannelInboundHandler<String> {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception {
System.err.println(msg); System.err.println(msg);
} }

View File

@ -39,7 +39,7 @@ public class TelnetServerHandler extends SimpleChannelInboundHandler<String> {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, String request) throws Exception { public void messageReceived(ChannelHandlerContext ctx, String request) throws Exception {
// Generate and write a response. // Generate and write a response.
String response; String response;
boolean close = false; boolean close = false;

View File

@ -41,7 +41,7 @@ public class UptimeClientHandler extends SimpleChannelInboundHandler<Object> {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
// Discard received data // Discard received data
} }

View File

@ -22,7 +22,7 @@ import io.netty.channel.SimpleChannelInboundHandler;
@Sharable @Sharable
public class UptimeServerHandler extends SimpleChannelInboundHandler<Object> { public class UptimeServerHandler extends SimpleChannelInboundHandler<Object> {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
// discard // discard
} }

View File

@ -94,7 +94,7 @@ public class WorldClockClientHandler extends SimpleChannelInboundHandler<LocalTi
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, LocalTimes times) throws Exception { public void messageReceived(ChannelHandlerContext ctx, LocalTimes times) throws Exception {
answer.add(times); answer.add(times);
} }

View File

@ -32,7 +32,7 @@ import static java.util.Calendar.*;
public class WorldClockServerHandler extends SimpleChannelInboundHandler<Locations> { public class WorldClockServerHandler extends SimpleChannelInboundHandler<Locations> {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Locations locations) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Locations locations) throws Exception {
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
LocalTimes.Builder builder = LocalTimes.newBuilder(); LocalTimes.Builder builder = LocalTimes.newBuilder();

View File

@ -489,7 +489,7 @@ public class ProxyHandlerTest {
} }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
String str = ((ByteBuf) msg).toString(CharsetUtil.US_ASCII); String str = ((ByteBuf) msg).toString(CharsetUtil.US_ASCII);
received.add(str); received.add(str);
if ("2".equals(str)) { if ("2".equals(str)) {
@ -543,7 +543,7 @@ public class ProxyHandlerTest {
} }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
fail("Unexpected message: " + msg); fail("Unexpected message: " + msg);
} }

View File

@ -158,7 +158,7 @@ abstract class ProxyServer {
private Channel backend; private Channel backend;
@Override @Override
protected final void channelRead0(final ChannelHandlerContext ctx, Object msg) throws Exception { protected final void messageReceived(final ChannelHandlerContext ctx, Object msg) throws Exception {
if (finished) { if (finished) {
received.add(ReferenceCountUtil.retain(msg)); received.add(ReferenceCountUtil.retain(msg));
flush(); flush();
@ -265,7 +265,7 @@ abstract class ProxyServer {
private boolean finished; private boolean finished;
@Override @Override
protected final void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { protected final void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
if (finished) { if (finished) {
String str = ((ByteBuf) msg).toString(CharsetUtil.US_ASCII); String str = ((ByteBuf) msg).toString(CharsetUtil.US_ASCII);
if ("A\n".equals(str)) { if ("A\n".equals(str)) {

View File

@ -28,7 +28,7 @@ final class UnresponsiveHandler extends SimpleChannelInboundHandler<Object> {
private UnresponsiveHandler() { } private UnresponsiveHandler() { }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
// Ignore // Ignore
} }
} }

View File

@ -174,7 +174,7 @@ public class CipherSuiteCanaryTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
if (serverPromise.trySuccess(null)) { if (serverPromise.trySuccess(null)) {
ctx.writeAndFlush(Unpooled.wrappedBuffer(new byte[] {'P', 'O', 'N', 'G'})); ctx.writeAndFlush(Unpooled.wrappedBuffer(new byte[] {'P', 'O', 'N', 'G'}));
} }
@ -210,7 +210,7 @@ public class CipherSuiteCanaryTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
clientPromise.trySuccess(null); clientPromise.trySuccess(null);
ctx.close(); ctx.close();
} }

View File

@ -240,7 +240,7 @@ public class OpenSslPrivateKeyMethodTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) { public void messageReceived(ChannelHandlerContext ctx, Object msg) {
if (serverPromise.trySuccess(null)) { if (serverPromise.trySuccess(null)) {
ctx.writeAndFlush(Unpooled.wrappedBuffer(new byte[] {'P', 'O', 'N', 'G'})); ctx.writeAndFlush(Unpooled.wrappedBuffer(new byte[] {'P', 'O', 'N', 'G'}));
} }
@ -276,7 +276,7 @@ public class OpenSslPrivateKeyMethodTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) { public void messageReceived(ChannelHandlerContext ctx, Object msg) {
clientPromise.trySuccess(null); clientPromise.trySuccess(null);
ctx.close(); ctx.close();
} }

View File

@ -238,7 +238,7 @@ public abstract class SSLEngineTest {
} }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
receiver.messageReceived(msg); receiver.messageReceived(msg);
latch.countDown(); latch.countDown();
} }

View File

@ -630,7 +630,8 @@ public class SslHandlerTest {
ch.pipeline().addLast(new SimpleChannelInboundHandler<ByteBuf>() { ch.pipeline().addLast(new SimpleChannelInboundHandler<ByteBuf>() {
private int readBytes; private int readBytes;
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx,
ByteBuf msg) throws Exception {
readBytes += msg.readableBytes(); readBytes += msg.readableBytes();
if (readBytes >= expectedBytes) { if (readBytes >= expectedBytes) {
serverReceiveLatch.countDown(); serverReceiveLatch.countDown();

View File

@ -45,7 +45,7 @@ public class HelloWorldHttp1Handler extends SimpleChannelInboundHandler<FullHttp
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, FullHttpRequest req) throws Exception { public void messageReceived(ChannelHandlerContext ctx, FullHttpRequest req) throws Exception {
if (HttpUtil.is100ContinueExpected(req)) { if (HttpUtil.is100ContinueExpected(req)) {
ctx.write(new DefaultFullHttpResponse(HTTP_1_1, CONTINUE, ctx.alloc().buffer(0))); ctx.write(new DefaultFullHttpResponse(HTTP_1_1, CONTINUE, ctx.alloc().buffer(0)));
} }

View File

@ -79,7 +79,7 @@ public class Http2ServerInitializer extends ChannelInitializer<SocketChannel> {
p.addLast(cleartextHttp2ServerUpgradeHandler); p.addLast(cleartextHttp2ServerUpgradeHandler);
p.addLast(new SimpleChannelInboundHandler<HttpMessage>() { p.addLast(new SimpleChannelInboundHandler<HttpMessage>() {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, HttpMessage msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, HttpMessage msg) throws Exception {
// If this handler is hit then no upgrade has been attempted and the client is just talking HTTP. // If this handler is hit then no upgrade has been attempted and the client is just talking HTTP.
System.err.println("Directly talking: " + msg.protocolVersion() + " (no upgrade was attempted)"); System.err.println("Directly talking: " + msg.protocolVersion() + " (no upgrade was attempted)");
ChannelPipeline pipeline = ctx.pipeline(); ChannelPipeline pipeline = ctx.pipeline();

View File

@ -41,7 +41,7 @@ public class HttpNativeServerHandler extends SimpleChannelInboundHandler<HttpObj
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) { public void messageReceived(ChannelHandlerContext ctx, HttpObject msg) {
if (msg instanceof HttpRequest) { if (msg instanceof HttpRequest) {
HttpRequest req = (HttpRequest) msg; HttpRequest req = (HttpRequest) msg;

View File

@ -159,7 +159,7 @@ public class SctpEchoTest extends AbstractSctpTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
byte[] actual = new byte[in.readableBytes()]; byte[] actual = new byte[in.readableBytes()];
in.readBytes(actual); in.readBytes(actual);

View File

@ -148,7 +148,7 @@ public abstract class AbstractSocketShutdownOutputByPeerTest<Socket> extends Abs
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
queue.offer(msg.readByte()); queue.offer(msg.readByte());
} }

View File

@ -57,7 +57,7 @@ public class DatagramMulticastTest extends AbstractDatagramTest {
sb.handler(new SimpleChannelInboundHandler<Object>() { sb.handler(new SimpleChannelInboundHandler<Object>() {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
// Nothing will be sent. // Nothing will be sent.
} }
}); });
@ -131,7 +131,7 @@ public class DatagramMulticastTest extends AbstractDatagramTest {
private volatile boolean fail; private volatile boolean fail;
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
if (done) { if (done) {
fail = true; fail = true;
} }

View File

@ -159,7 +159,7 @@ public class DatagramUnicastTest extends AbstractDatagramTest {
try { try {
cb.handler(new SimpleChannelInboundHandler<Object>() { cb.handler(new SimpleChannelInboundHandler<Object>() {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msgs) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msgs) throws Exception {
// Nothing will be sent. // Nothing will be sent.
} }
}); });
@ -236,7 +236,7 @@ public class DatagramUnicastTest extends AbstractDatagramTest {
final AtomicReference<Throwable> clientErrorRef = new AtomicReference<Throwable>(); final AtomicReference<Throwable> clientErrorRef = new AtomicReference<Throwable>();
cb.handler(new SimpleChannelInboundHandler<DatagramPacket>() { cb.handler(new SimpleChannelInboundHandler<DatagramPacket>() {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
try { try {
ByteBuf buf = msg.content(); ByteBuf buf = msg.content();
assertEquals(bytes.length, buf.readableBytes()); assertEquals(bytes.length, buf.readableBytes());
@ -345,7 +345,7 @@ public class DatagramUnicastTest extends AbstractDatagramTest {
protected void initChannel(Channel ch) throws Exception { protected void initChannel(Channel ch) throws Exception {
ch.pipeline().addLast(new SimpleChannelInboundHandler<DatagramPacket>() { ch.pipeline().addLast(new SimpleChannelInboundHandler<DatagramPacket>() {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
try { try {
if (sender == null) { if (sender == null) {
assertNotNull(msg.sender()); assertNotNull(msg.sender());

View File

@ -94,7 +94,7 @@ public class SocketBufReleaseTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
// discard // discard
} }

View File

@ -106,7 +106,7 @@ public class SocketCancelWriteTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
counter += in.readableBytes(); counter += in.readableBytes();
received.writeBytes(in); received.writeBytes(in);
} }

View File

@ -71,7 +71,7 @@ public class SocketDataReadInitialStateTest extends AbstractSocketTest {
serverConnectedChannelRef.set(ch); serverConnectedChannelRef.set(ch);
ch.pipeline().addLast(new SimpleChannelInboundHandler<ByteBuf>() { ch.pipeline().addLast(new SimpleChannelInboundHandler<ByteBuf>() {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) { protected void messageReceived(ChannelHandlerContext ctx, ByteBuf msg) {
ctx.writeAndFlush(msg.retainedDuplicate()); ctx.writeAndFlush(msg.retainedDuplicate());
serverReadLatch.countDown(); serverReadLatch.countDown();
} }
@ -85,7 +85,7 @@ public class SocketDataReadInitialStateTest extends AbstractSocketTest {
protected void initChannel(Channel ch) { protected void initChannel(Channel ch) {
ch.pipeline().addLast(new SimpleChannelInboundHandler<Object>() { ch.pipeline().addLast(new SimpleChannelInboundHandler<Object>() {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) { protected void messageReceived(ChannelHandlerContext ctx, Object msg) {
clientReadLatch.countDown(); clientReadLatch.countDown();
} }
}); });
@ -147,7 +147,7 @@ public class SocketDataReadInitialStateTest extends AbstractSocketTest {
protected void initChannel(Channel ch) { protected void initChannel(Channel ch) {
ch.pipeline().addLast(new SimpleChannelInboundHandler<ByteBuf>() { ch.pipeline().addLast(new SimpleChannelInboundHandler<ByteBuf>() {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) { protected void messageReceived(ChannelHandlerContext ctx, ByteBuf msg) {
ctx.writeAndFlush(msg.retainedDuplicate()); ctx.writeAndFlush(msg.retainedDuplicate());
serverReadLatch.countDown(); serverReadLatch.countDown();
} }
@ -160,7 +160,7 @@ public class SocketDataReadInitialStateTest extends AbstractSocketTest {
protected void initChannel(Channel ch) { protected void initChannel(Channel ch) {
ch.pipeline().addLast(new SimpleChannelInboundHandler<Object>() { ch.pipeline().addLast(new SimpleChannelInboundHandler<Object>() {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) { protected void messageReceived(ChannelHandlerContext ctx, Object msg) {
clientReadLatch.countDown(); clientReadLatch.countDown();
} }
}); });

View File

@ -177,7 +177,7 @@ public class SocketEchoTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
byte[] actual = new byte[in.readableBytes()]; byte[] actual = new byte[in.readableBytes()];
in.readBytes(actual); in.readBytes(actual);

View File

@ -109,7 +109,7 @@ public class SocketFileRegionTest extends AbstractSocketTest {
sb.childHandler(new SimpleChannelInboundHandler<ByteBuf>() { sb.childHandler(new SimpleChannelInboundHandler<ByteBuf>() {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) { protected void messageReceived(ChannelHandlerContext ctx, ByteBuf msg) {
// Just drop the message. // Just drop the message.
} }
}); });
@ -158,7 +158,7 @@ public class SocketFileRegionTest extends AbstractSocketTest {
ChannelHandler ch = new SimpleChannelInboundHandler<Object>() { ChannelHandler ch = new SimpleChannelInboundHandler<Object>() {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
} }
@Override @Override
@ -252,7 +252,7 @@ public class SocketFileRegionTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
byte[] actual = new byte[in.readableBytes()]; byte[] actual = new byte[in.readableBytes()];
in.readBytes(actual); in.readBytes(actual);

View File

@ -157,7 +157,7 @@ public class SocketFixedLengthEchoTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
assertEquals(1024, msg.readableBytes()); assertEquals(1024, msg.readableBytes());
byte[] actual = new byte[msg.readableBytes()]; byte[] actual = new byte[msg.readableBytes()];

View File

@ -184,7 +184,7 @@ public class SocketGatheringWriteTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
received.writeBytes(in); received.writeBytes(in);
if (received.readableBytes() >= expectedBytes) { if (received.readableBytes() >= expectedBytes) {
doneReadingPromise.setSuccess(null); doneReadingPromise.setSuccess(null);
@ -223,7 +223,7 @@ public class SocketGatheringWriteTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
} }
@Override @Override

View File

@ -311,7 +311,7 @@ public class SocketHalfClosedTest extends AbstractSocketTest {
} }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
bytesRead += msg.readableBytes(); bytesRead += msg.readableBytes();
if (bytesRead >= expectedBytes) { if (bytesRead >= expectedBytes) {
// We write a reply and immediately close our end of the socket. // We write a reply and immediately close our end of the socket.
@ -373,7 +373,7 @@ public class SocketHalfClosedTest extends AbstractSocketTest {
} }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
bytesRead += msg.readableBytes(); bytesRead += msg.readableBytes();
if (bytesRead >= expectedBytes) { if (bytesRead >= expectedBytes) {
if (!seenOutputShutdown) { if (!seenOutputShutdown) {

View File

@ -260,7 +260,7 @@ public class SocketShutdownOutputBySelfTest extends AbstractClientSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
queue.offer(msg.readByte()); queue.offer(msg.readByte());
} }

View File

@ -267,6 +267,6 @@ public class SocketSslClientRenegotiateTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception { } public void messageReceived(ChannelHandlerContext ctx, ByteBuf in) throws Exception { }
} }
} }

View File

@ -504,7 +504,7 @@ public class SocketSslEchoTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
byte[] actual = new byte[in.readableBytes()]; byte[] actual = new byte[in.readableBytes()];
in.readBytes(actual); in.readBytes(actual);
@ -533,7 +533,7 @@ public class SocketSslEchoTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
byte[] actual = new byte[in.readableBytes()]; byte[] actual = new byte[in.readableBytes()];
in.readBytes(actual); in.readBytes(actual);

View File

@ -190,7 +190,7 @@ public class SocketSslGreetingTest extends AbstractSocketTest {
final CountDownLatch latch = new CountDownLatch(1); final CountDownLatch latch = new CountDownLatch(1);
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf buf) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf buf) throws Exception {
assertEquals('a', buf.readByte()); assertEquals('a', buf.readByte());
assertFalse(buf.isReadable()); assertFalse(buf.isReadable());
latch.countDown(); latch.countDown();
@ -214,7 +214,7 @@ public class SocketSslGreetingTest extends AbstractSocketTest {
final AtomicReference<Throwable> exception = new AtomicReference<>(); final AtomicReference<Throwable> exception = new AtomicReference<>();
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception {
// discard // discard
} }

View File

@ -183,7 +183,7 @@ public class SocketSslSessionReuseTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
byte[] actual = new byte[in.readableBytes()]; byte[] actual = new byte[in.readableBytes()];
in.readBytes(actual); in.readBytes(actual);
ctx.close(); ctx.close();

View File

@ -230,7 +230,7 @@ public class SocketStartTlsTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception {
if ("StartTlsResponse".equals(msg)) { if ("StartTlsResponse".equals(msg)) {
ctx.pipeline().addAfter("logger", "ssl", sslHandler); ctx.pipeline().addAfter("logger", "ssl", sslHandler);
handshakeFuture = sslHandler.handshakeFuture(); handshakeFuture = sslHandler.handshakeFuture();
@ -284,7 +284,7 @@ public class SocketStartTlsTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception {
if ("StartTlsRequest".equals(msg)) { if ("StartTlsRequest".equals(msg)) {
ctx.pipeline().addAfter("logger", "ssl", sslHandler); ctx.pipeline().addAfter("logger", "ssl", sslHandler);
ctx.writeAndFlush("StartTlsResponse\n"); ctx.writeAndFlush("StartTlsResponse\n");

View File

@ -147,7 +147,7 @@ public class SocketStringEchoTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception {
if (!data[dataIndex].equals(msg)) { if (!data[dataIndex].equals(msg)) {
donePromise.tryFailure(new IllegalStateException("index: " + dataIndex + " didn't match!")); donePromise.tryFailure(new IllegalStateException("index: " + dataIndex + " didn't match!"));
ctx.close(); ctx.close();

View File

@ -406,7 +406,7 @@ public class TrafficShapingHandlerTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
long lastTimestamp = 0; long lastTimestamp = 0;
loggerClient.debug("Step: " + step + " Read: " + in.readableBytes() / 8 + " blocks"); loggerClient.debug("Step: " + step + " Read: " + in.readableBytes() / 8 + " blocks");
while (in.isReadable()) { while (in.isReadable()) {
@ -469,7 +469,7 @@ public class TrafficShapingHandlerTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(final ChannelHandlerContext ctx, ByteBuf in) throws Exception { public void messageReceived(final ChannelHandlerContext ctx, ByteBuf in) throws Exception {
byte[] actual = new byte[in.readableBytes()]; byte[] actual = new byte[in.readableBytes()];
int nb = actual.length / messageSize; int nb = actual.length / messageSize;
loggerServer.info("Step: " + step + " Read: " + nb + " blocks"); loggerServer.info("Step: " + step + " Read: " + nb + " blocks");

View File

@ -98,7 +98,7 @@ public class EpollDatagramScatteringReadTest extends AbstractDatagramTest {
try { try {
cb.handler(new SimpleChannelInboundHandler<Object>() { cb.handler(new SimpleChannelInboundHandler<Object>() {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msgs) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msgs) throws Exception {
// Nothing will be sent. // Nothing will be sent.
} }
}); });
@ -120,7 +120,7 @@ public class EpollDatagramScatteringReadTest extends AbstractDatagramTest {
} }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) { protected void messageReceived(ChannelHandlerContext ctx, DatagramPacket msg) {
assertEquals(ccAddress, msg.sender()); assertEquals(ccAddress, msg.sender());
assertEquals(bytes.length, msg.content().readableBytes()); assertEquals(bytes.length, msg.content().readableBytes());

View File

@ -247,7 +247,7 @@ public class EpollSpliceTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
byte[] actual = new byte[in.readableBytes()]; byte[] actual = new byte[in.readableBytes()];
in.readBytes(actual); in.readBytes(actual);

View File

@ -190,7 +190,7 @@ public abstract class DetectPeerCloseWithoutReadTest {
} }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) { protected void messageReceived(ChannelHandlerContext ctx, ByteBuf msg) {
bytesRead.addAndGet(msg.readableBytes()); bytesRead.addAndGet(msg.readableBytes());
if (extraReadRequested) { if (extraReadRequested) {

View File

@ -55,7 +55,7 @@ import java.net.SocketAddress;
* <b>private boolean loggedIn;</b> * <b>private boolean loggedIn;</b>
* *
* {@code @Override} * {@code @Override}
* public void channelRead0({@link ChannelHandlerContext} ctx, Message message) { * public void messageReceived({@link ChannelHandlerContext} ctx, Message message) {
* if (message instanceof LoginMessage) { * if (message instanceof LoginMessage) {
* authenticate((LoginMessage) message); * authenticate((LoginMessage) message);
* <b>loggedIn = true;</b> * <b>loggedIn = true;</b>

View File

@ -28,7 +28,7 @@ import io.netty.util.internal.TypeParameterMatcher;
* {@link SimpleChannelInboundHandler}&lt;{@link String}&gt; { * {@link SimpleChannelInboundHandler}&lt;{@link String}&gt; {
* *
* {@code @Override} * {@code @Override}
* protected void channelRead0({@link ChannelHandlerContext} ctx, {@link String} message) * protected void messageReceived({@link ChannelHandlerContext} ctx, {@link String} message)
* throws {@link Exception} { * throws {@link Exception} {
* System.out.println(message); * System.out.println(message);
* } * }
@ -38,12 +38,6 @@ import io.netty.util.internal.TypeParameterMatcher;
* Be aware that depending of the constructor parameters it will release all handled messages by passing them to * Be aware that depending of the constructor parameters it will release all handled messages by passing them to
* {@link ReferenceCountUtil#release(Object)}. In this case you may need to use * {@link ReferenceCountUtil#release(Object)}. In this case you may need to use
* {@link ReferenceCountUtil#retain(Object)} if you pass the object to the next handler in the {@link ChannelPipeline}. * {@link ReferenceCountUtil#retain(Object)} if you pass the object to the next handler in the {@link ChannelPipeline}.
*
* <h3>Forward compatibility notice</h3>
* <p>
* Please keep in mind that {@link #channelRead0(ChannelHandlerContext, I)} will be renamed to
* {@code messageReceived(ChannelHandlerContext, I)} in 5.0.
* </p>
*/ */
public abstract class SimpleChannelInboundHandler<I> implements ChannelInboundHandler { public abstract class SimpleChannelInboundHandler<I> implements ChannelInboundHandler {
@ -102,7 +96,7 @@ public abstract class SimpleChannelInboundHandler<I> implements ChannelInboundHa
if (acceptInboundMessage(msg)) { if (acceptInboundMessage(msg)) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
I imsg = (I) msg; I imsg = (I) msg;
channelRead0(ctx, imsg); messageReceived(ctx, imsg);
} else { } else {
release = false; release = false;
ctx.fireChannelRead(msg); ctx.fireChannelRead(msg);
@ -115,9 +109,6 @@ public abstract class SimpleChannelInboundHandler<I> implements ChannelInboundHa
} }
/** /**
* <strong>Please keep in mind that this method will be renamed to
* {@code messageReceived(ChannelHandlerContext, I)} in 5.0.</strong>
*
* Is called for each message of type {@link I}. * Is called for each message of type {@link I}.
* *
* @param ctx the {@link ChannelHandlerContext} which this {@link SimpleChannelInboundHandler} * @param ctx the {@link ChannelHandlerContext} which this {@link SimpleChannelInboundHandler}
@ -125,5 +116,5 @@ public abstract class SimpleChannelInboundHandler<I> implements ChannelInboundHa
* @param msg the message to handle * @param msg the message to handle
* @throws Exception is thrown if an error occurred * @throws Exception is thrown if an error occurred
*/ */
protected abstract void channelRead0(ChannelHandlerContext ctx, I msg) throws Exception; protected abstract void messageReceived(ChannelHandlerContext ctx, I msg) throws Exception;
} }

View File

@ -198,7 +198,7 @@ public class LocalChannelTest {
.channel(LocalServerChannel.class) .channel(LocalServerChannel.class)
.childHandler(new SimpleChannelInboundHandler<Object>() { .childHandler(new SimpleChannelInboundHandler<Object>() {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
ctx.close(); ctx.close();
latch.countDown(); latch.countDown();
} }
@ -213,7 +213,7 @@ public class LocalChannelTest {
.channel(LocalChannel.class) .channel(LocalChannel.class)
.handler(new SimpleChannelInboundHandler<Object>() { .handler(new SimpleChannelInboundHandler<Object>() {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
// discard // discard
} }
}); });
@ -867,7 +867,7 @@ public class LocalChannelTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf buffer) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf buffer) throws Exception {
// Just drop the buffer // Just drop the buffer
} }
}); });
@ -880,7 +880,7 @@ public class LocalChannelTest {
ch.pipeline().addLast(new SimpleChannelInboundHandler<ByteBuf>() { ch.pipeline().addLast(new SimpleChannelInboundHandler<ByteBuf>() {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf buffer) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf buffer) throws Exception {
while (buffer.isReadable()) { while (buffer.isReadable()) {
// Fill the ChannelOutboundBuffer with multiple buffers // Fill the ChannelOutboundBuffer with multiple buffers
ctx.write(buffer.readRetainedSlice(1)); ctx.write(buffer.readRetainedSlice(1));

View File

@ -179,7 +179,7 @@ public class NioSocketChannelTest extends AbstractNioChannelTest<NioSocketChanne
ChannelPipeline pipeline = ch.pipeline(); ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new SimpleChannelInboundHandler<ByteBuf>() { pipeline.addLast(new SimpleChannelInboundHandler<ByteBuf>() {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf byteBuf) { protected void messageReceived(ChannelHandlerContext ctx, ByteBuf byteBuf) {
// We was able to read something from the Channel after reregister. // We was able to read something from the Channel after reregister.
latch.countDown(); latch.countDown();
} }