GeezerVison is showing github.com — Merge ChannelInboundConsumingHandler into SimpleChannelInboundHandler · netty/netty@a969613
File treeExpand file treeCollapse file tree Open diff view settings main/java/io/netty/handler/codec/http/websocketx test/java/io/netty/handler/codec/http/websocketx
example/src/main/java/io/netty/example testsuite/src/test/java/io/netty/testsuite/transport test/java/io/netty/channel/local
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientProtocolHandshakeHandler.java -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -48,7 +48,6 @@ public void operationComplete(ChannelFuture future) throws Exception { | 48 | 48 | protected void messageReceived(ChannelHandlerContext ctx, FullHttpResponse msg) throws Exception { | 49 | 49 | if (!handshaker.isHandshakeComplete()) { | 50 | 50 | handshaker.finishHandshake(ctx.channel(), msg); | 51 | | - msg.release(); | 52 | 51 | ctx.fireUserEventTriggered( | 53 | 52 | WebSocketClientProtocolHandler.ClientHandshakeStateEvent.HANDSHAKE_COMPLETE); | 54 | 53 | ctx.pipeline().remove(this); | |
Collapse file Copy file name to clipboardExpand all lines: codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java -2Lines changed: 0 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 20 | 20 | import io.netty.channel.ChannelHandler; | 21 | 21 | import io.netty.channel.ChannelHandlerContext; | 22 | 22 | import io.netty.channel.ChannelInboundHandler; | 23 | | -import io.netty.channel.ChannelInboundHandlerAdapter; | 24 | 23 | import io.netty.channel.ChannelPipeline; | 25 | 24 | import io.netty.channel.MessageList; | 26 | 25 | import io.netty.channel.SimpleChannelInboundHandler; | @@ -125,7 +124,6 @@ static ChannelHandler forbiddenHttpRequestResponder() { | 125 | 124 | return new SimpleChannelInboundHandler<FullHttpRequest>() { | 126 | 125 | @Override | 127 | 126 | protected void messageReceived(ChannelHandlerContext ctx, FullHttpRequest msg) throws Exception { | 128 | | - msg.release(); | 129 | 127 | FullHttpResponse response = | 130 | 128 | new DefaultFullHttpResponse(HTTP_1_1, HttpResponseStatus.FORBIDDEN); | 131 | 129 | ctx.channel().write(response); | |
Collapse file Copy file name to clipboardExpand all lines: codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 17 | 17 |
| 18 | 18 | import io.netty.channel.ChannelHandler; | 19 | 19 | import io.netty.channel.ChannelHandlerContext; | 20 | | -import io.netty.channel.ChannelInboundConsumingHandler; | 21 | 20 | import io.netty.channel.ChannelOutboundHandlerAdapter; | 22 | 21 | import io.netty.channel.ChannelPromise; | 23 | 22 | import io.netty.channel.MessageList; | | 23 | +import io.netty.channel.SimpleChannelInboundHandler; | 24 | 24 | import io.netty.channel.embedded.EmbeddedChannel; | 25 | 25 | import io.netty.handler.codec.http.DefaultFullHttpRequest; | 26 | 26 | import io.netty.handler.codec.http.FullHttpRequest; | @@ -156,11 +156,11 @@ public void write(ChannelHandlerContext ctx, MessageList<Object> msgs, ChannelPr | 156 | 156 | } | 157 | 157 | } | 158 | 158 |
| 159 | | - private static class CustomTextFrameHandler extends ChannelInboundConsumingHandler<TextWebSocketFrame> { | | 159 | + private static class CustomTextFrameHandler extends SimpleChannelInboundHandler<TextWebSocketFrame> { | 160 | 160 | private String content; | 161 | 161 |
| 162 | 162 | @Override | 163 | | - public void consume(ChannelHandlerContext ctx, TextWebSocketFrame msg) throws Exception { | | 163 | + public void messageReceived(ChannelHandlerContext ctx, TextWebSocketFrame msg) throws Exception { | 164 | 164 | assertNull(content); | 165 | 165 | content = "processed: " + msg.text(); | 166 | 166 | } | |
Collapse file Copy file name to clipboardExpand all lines: example/src/main/java/io/netty/example/applet/AppletDiscardServer.java +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 19 | 19 | import io.netty.buffer.ByteBuf; | 20 | 20 | import io.netty.channel.ChannelFuture; | 21 | 21 | import io.netty.channel.ChannelHandlerContext; | 22 | | -import io.netty.channel.ChannelInboundConsumingHandler; | 23 | 22 | import io.netty.channel.ChannelInitializer; | 24 | 23 | import io.netty.channel.EventLoopGroup; | | 24 | +import io.netty.channel.SimpleChannelInboundHandler; | 25 | 25 | import io.netty.channel.nio.NioEventLoopGroup; | 26 | 26 | import io.netty.channel.socket.SocketChannel; | 27 | 27 | import io.netty.channel.socket.nio.NioServerSocketChannel; | @@ -72,10 +72,10 @@ public void destroy() { | 72 | 72 | } | 73 | 73 | } | 74 | 74 |
| 75 | | - private static final class DiscardServerHandler extends ChannelInboundConsumingHandler<ByteBuf> { | | 75 | + private static final class DiscardServerHandler extends SimpleChannelInboundHandler<ByteBuf> { | 76 | 76 |
| 77 | 77 | @Override | 78 | | - public void consume(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { | | 78 | + public void messageReceived(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { | 79 | 79 | System.out.println("Received: " + msg.toString(CharsetUtil.UTF_8)); | 80 | 80 | } | 81 | 81 |
| |
Collapse file Copy file name to clipboardExpand all lines: example/src/main/java/io/netty/example/factorial/FactorialClientHandler.java +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -71,8 +71,7 @@ public void channelActive(ChannelHandlerContext ctx) { | 71 | 71 | } | 72 | 72 |
| 73 | 73 | @Override | 74 | | - public void messageReceived( | 75 | | - ChannelHandlerContext ctx, final BigInteger msg) { | | 74 | + public void messageReceived(ChannelHandlerContext ctx, final BigInteger msg) { | 76 | 75 | receivedMessages ++; | 77 | 76 | if (receivedMessages == count) { | 78 | 77 | // Offer the answer after closing the connection. | |
Collapse file Copy file name to clipboardExpand all lines: example/src/main/java/io/netty/example/filetransfer/FileServer.java +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 18 | 18 | import io.netty.bootstrap.ServerBootstrap; | 19 | 19 | import io.netty.channel.ChannelFuture; | 20 | 20 | import io.netty.channel.ChannelHandlerContext; | 21 | | -import io.netty.channel.ChannelInboundConsumingHandler; | 22 | 21 | import io.netty.channel.ChannelInitializer; | 23 | 22 | import io.netty.channel.ChannelOption; | 24 | 23 | import io.netty.channel.DefaultFileRegion; | 25 | 24 | import io.netty.channel.EventLoopGroup; | 26 | 25 | import io.netty.channel.FileRegion; | 27 | 26 | import io.netty.channel.MessageList; | | 27 | +import io.netty.channel.SimpleChannelInboundHandler; | 28 | 28 | import io.netty.channel.nio.NioEventLoopGroup; | 29 | 29 | import io.netty.channel.socket.SocketChannel; | 30 | 30 | import io.netty.channel.socket.nio.NioServerSocketChannel; | @@ -92,9 +92,9 @@ public static void main(String[] args) throws Exception { | 92 | 92 | new FileServer(port).run(); | 93 | 93 | } | 94 | 94 |
| 95 | | - private static final class FileHandler extends ChannelInboundConsumingHandler<String> { | | 95 | + private static final class FileHandler extends SimpleChannelInboundHandler<String> { | 96 | 96 | @Override | 97 | | - public void consume(ChannelHandlerContext ctx, String msg) throws Exception { | | 97 | + public void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception { | 98 | 98 | File file = new File(msg); | 99 | 99 | if (file.exists()) { | 100 | 100 | if (!file.isFile()) { | |
Collapse file Copy file name to clipboardExpand all lines: example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 19 | 19 | import io.netty.channel.ChannelFuture; | 20 | 20 | import io.netty.channel.ChannelFutureListener; | 21 | 21 | import io.netty.channel.ChannelHandlerContext; | 22 | | -import io.netty.channel.ChannelInboundConsumingHandler; | 23 | 22 | import io.netty.channel.MessageList; | | 23 | +import io.netty.channel.SimpleChannelInboundHandler; | 24 | 24 | import io.netty.handler.codec.http.DefaultFullHttpResponse; | 25 | 25 | import io.netty.handler.codec.http.DefaultHttpResponse; | 26 | 26 | import io.netty.handler.codec.http.FullHttpRequest; | | 98 | 98 | * | 99 | 99 | * </pre> | 100 | 100 | */ | 101 | | -public class HttpStaticFileServerHandler extends ChannelInboundConsumingHandler<FullHttpRequest> { | | 101 | +public class HttpStaticFileServerHandler extends SimpleChannelInboundHandler<FullHttpRequest> { | 102 | 102 |
| 103 | 103 | public static final String HTTP_DATE_FORMAT = "EEE, dd MMM yyyy HH:mm:ss zzz"; | 104 | 104 | public static final String HTTP_DATE_GMT_TIMEZONE = "GMT"; | 105 | 105 | public static final int HTTP_CACHE_SECONDS = 60; | 106 | 106 |
| 107 | 107 | @Override | 108 | | - public void consume( | | 108 | + public void messageReceived( | 109 | 109 | ChannelHandlerContext ctx, FullHttpRequest request) throws Exception { | 110 | 110 | if (!request.getDecoderResult().isSuccess()) { | 111 | 111 | sendError(ctx, BAD_REQUEST); | |
Collapse file Copy file name to clipboardExpand all lines: example/src/main/java/io/netty/example/http/helloworld/HttpHelloWorldServerHandler.java +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 19 | 19 | import io.netty.buffer.Unpooled; | 20 | 20 | import io.netty.channel.ChannelFutureListener; | 21 | 21 | import io.netty.channel.ChannelHandlerContext; | 22 | | -import io.netty.channel.ChannelInboundConsumingHandler; | 23 | 22 | import io.netty.channel.MessageList; | | 23 | +import io.netty.channel.SimpleChannelInboundHandler; | 24 | 24 | import io.netty.handler.codec.http.DefaultFullHttpResponse; | 25 | 25 | import io.netty.handler.codec.http.FullHttpResponse; | 26 | 26 | import io.netty.handler.codec.http.HttpRequest; | | 31 | 31 | import static io.netty.handler.codec.http.HttpResponseStatus.*; | 32 | 32 | import static io.netty.handler.codec.http.HttpVersion.*; | 33 | 33 |
| 34 | | -public class HttpHelloWorldServerHandler extends ChannelInboundConsumingHandler<Object> { | | 34 | +public class HttpHelloWorldServerHandler extends SimpleChannelInboundHandler<Object> { | 35 | 35 | private static final ByteBuf CONTENT = | 36 | 36 | Unpooled.unreleasableBuffer(Unpooled.copiedBuffer("Hello World", CharsetUtil.US_ASCII)); | 37 | 37 |
| 38 | 38 | private MessageList<Object> out; | 39 | 39 | @Override | 40 | | - protected void beginConsume(ChannelHandlerContext ctx) { | | 40 | + protected void beginMessageReceived(ChannelHandlerContext ctx) { | 41 | 41 | out = MessageList.newInstance(); | 42 | 42 | } | 43 | 43 |
| 44 | 44 | @Override | 45 | | - protected void endConsume(ChannelHandlerContext ctx) { | | 45 | + protected void endMessageReceived(ChannelHandlerContext ctx) { | 46 | 46 | ctx.write(out); | 47 | 47 | out = null; | 48 | 48 | } | 49 | 49 |
| 50 | 50 | @Override | 51 | | - public void consume(ChannelHandlerContext ctx, Object msg) throws Exception { | | 51 | + public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception { | 52 | 52 | if (msg instanceof HttpRequest) { | 53 | 53 | HttpRequest req = (HttpRequest) msg; | 54 | 54 |
| |
Collapse file Copy file name to clipboardExpand all lines: example/src/main/java/io/netty/example/http/snoop/HttpSnoopClientHandler.java +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 16 | 16 | package io.netty.example.http.snoop; | 17 | 17 |
| 18 | 18 | import io.netty.channel.ChannelHandlerContext; | 19 | | -import io.netty.channel.ChannelInboundConsumingHandler; | | 19 | +import io.netty.channel.SimpleChannelInboundHandler; | 20 | 20 | import io.netty.handler.codec.http.HttpContent; | 21 | 21 | import io.netty.handler.codec.http.HttpHeaders; | 22 | 22 | import io.netty.handler.codec.http.HttpObject; | 23 | 23 | import io.netty.handler.codec.http.HttpResponse; | 24 | 24 | import io.netty.handler.codec.http.LastHttpContent; | 25 | 25 | import io.netty.util.CharsetUtil; | 26 | 26 |
| 27 | | -public class HttpSnoopClientHandler extends ChannelInboundConsumingHandler<HttpObject> { | | 27 | +public class HttpSnoopClientHandler extends SimpleChannelInboundHandler<HttpObject> { | 28 | 28 |
| 29 | 29 | @Override | 30 | | - public void consume(ChannelHandlerContext ctx, HttpObject msg) throws Exception { | | 30 | + public void messageReceived(ChannelHandlerContext ctx, HttpObject msg) throws Exception { | 31 | 31 | if (msg instanceof HttpResponse) { | 32 | 32 | HttpResponse response = (HttpResponse) msg; | 33 | 33 |
| |
Collapse file Copy file name to clipboardExpand all lines: example/src/main/java/io/netty/example/http/upload/HttpUploadClientHandler.java +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 16 | 16 | package io.netty.example.http.upload; | 17 | 17 |
| 18 | 18 | import io.netty.channel.ChannelHandlerContext; | 19 | | -import io.netty.channel.ChannelInboundConsumingHandler; | | 19 | +import io.netty.channel.SimpleChannelInboundHandler; | 20 | 20 | import io.netty.handler.codec.http.HttpContent; | 21 | 21 | import io.netty.handler.codec.http.HttpHeaders; | 22 | 22 | import io.netty.handler.codec.http.HttpObject; | | 29 | 29 | /** | 30 | 30 | * Handler that just dumps the contents of the response from the server | 31 | 31 | */ | 32 | | -public class HttpUploadClientHandler extends ChannelInboundConsumingHandler<HttpObject> { | | 32 | +public class HttpUploadClientHandler extends SimpleChannelInboundHandler<HttpObject> { | 33 | 33 |
| 34 | 34 | private static final Logger logger = Logger.getLogger(HttpUploadClientHandler.class.getName()); | 35 | 35 |
| 36 | 36 | private boolean readingChunks; | 37 | 37 |
| 38 | 38 | @Override | 39 | | - public void consume(ChannelHandlerContext ctx, HttpObject msg) throws Exception { | | 39 | + public void messageReceived(ChannelHandlerContext ctx, HttpObject msg) throws Exception { | 40 | 40 | if (msg instanceof HttpResponse) { | 41 | 41 | HttpResponse response = (HttpResponse) msg; | 42 | 42 |
| |
|