GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Replace *FutureListener* usage with Lambda where possible (#16032) · netty/netty@890fa05

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • codec-base/src/main/java/io/netty/handler/codec
    • MessageAggregator.java
  • codec-compression/src
    • main/java/io/netty/handler/codec/compression
      • EncoderUtil.java
      • JZlibEncoder.java
    • test/java/io/netty/handler/codec/compression
      • Lz4FrameEncoderTest.java
  • codec-http2/src
    • main/java/io/netty/handler/codec/http2
      • AbstractHttp2StreamChannel.java
      • DefaultHttp2ConnectionEncoder.java
      • Http2ConnectionHandler.java
      • Http2ControlFrameLimitEncoder.java
      • Http2FrameCodec.java
      • Http2MultiplexHandler.java
      • Http2StreamChannelBootstrap.java
    • test/java/io/netty/handler/codec/http2
      • DefaultHttp2ConnectionTest.java
      • DefaultHttp2PushPromiseFrameTest.java
      • Http2ConnectionHandlerTest.java
      • Http2ConnectionRoundtripTest.java
      • Http2FrameCodecTest.java
      • Http2MultiplexTest.java
      • Http2MultiplexTransportTest.java
  • codec-http/src
    • main
      • java/io/netty/handler/codec
        • http
          • HttpObjectAggregator.java
          • websocketx
            • WebSocketClientHandshaker.java
            • WebSocketClientProtocolHandshakeHandler.java
            • WebSocketProtocolHandler.java
            • WebSocketServerHandshaker.java
            • WebSocketServerProtocolHandshakeHandler.java
            • extensions
              • WebSocketServerExtensionHandler.java
        • spdy
          • SpdyFrameCodec.java
          • SpdySessionHandler.java
      • resources/META-INF/native-image/io.netty/netty5-codec-http/generated/handlers
        • reflect-config.json
    • test/java/io/netty/handler/codec/http
      • HttpClientCodecTest.java
      • HttpServerUpgradeHandlerTest.java
      • websocketx
        • WebSocketHandshakeHandOverTest.java
  • codec-native-quic/src/test/java/io/netty/handler/codec/quic
    • QuicStreamShutdownTest.java
  • common/src
    • main/java/io/netty/util/concurrent
      • MultithreadEventExecutorGroup.java
      • PromiseNotifier.java
    • test/java/io/netty/util/concurrent
      • DefaultPromiseTest.java
      • UnorderedThreadPoolEventExecutorTest.java
  • example/src/main/java/io/netty/example
    • discard
      • DiscardClientHandler.java
    • factorial
      • FactorialClientHandler.java
    • haproxy
      • HAProxyHandler.java
    • proxy
      • HexDumpProxyBackendHandler.java
      • HexDumpProxyFrontendHandler.java
    • redis
      • RedisClient.java
    • securechat
      • SecureChatServerHandler.java
    • socksproxy
      • SocksServerConnectHandler.java
    • stomp/websocket
      • StompChatHandler.java
      • StompWebSocketChatServer.java
    • uptime
      • UptimeClient.java
  • handler-proxy/src
    • main/java/io/netty/handler/proxy
      • ProxyHandler.java
    • test/java/io/netty/handler/proxy
      • ProxyHandlerTest.java
      • ProxyServer.java
  • handler-ssl-ocsp/src/main/java/io/netty/handler/ssl/ocsp
    • OcspClient.java
    • OcspServerCertificateValidator.java
  • handler/src
    • main/java/io/netty/handler
      • address
        • DynamicAddressConnectHandler.java
        • ResolveAddressHandler.java
      • ipfilter
        • UniqueIpFilter.java
      • ssl
        • SslClientHelloHandler.java
        • SslHandler.java
      • stream
        • ChunkedWriteHandler.java
      • timeout
        • IdleStateHandler.java
    • test/java/io/netty/handler
      • flush
        • FlushConsolidationHandlerTest.java
      • ssl
        • ParameterizedSslHandlerTest.java
        • RenegotiateTest.java
        • SslHandlerTest.java
      • stream
        • ChunkedWriteHandlerTest.java
  • resolver-dns/src
    • main
      • java/io/netty/resolver/dns
        • DnsNameResolver.java
        • DnsQueryContext.java
        • DnsResolveContext.java
        • InflightNameResolver.java
      • resources/META-INF/native-image/io.netty/netty5-resolver-dns/generated/handlers
        • reflect-config.json
    • test/java/io/netty/resolver/dns
      • DnsAddressResolverGroupTest.java
  • resolver/src/main/java/io/netty/resolver
    • AddressResolverGroup.java
    • CompositeNameResolver.java
    • InetSocketAddressResolver.java
    • RoundRobinInetAddressResolver.java
  • testsuite/src/main/java/io/netty/testsuite/transport/socket
    • AbstractSocketReuseFdTest.java
    • SocketBufReleaseTest.java
    • SocketHalfClosedTest.java
    • SocketSslEchoTest.java
    • SocketSslLargeCertificateTest.java
  • transport-native-epoll/src/test/java/io/netty/channel/epoll
    • EpollDomainSocketFdTest.java
  • transport-native-io_uring/src/test/java/io/netty/channel/uring
    • IoUringDomainSocketFdTest.java
  • transport-native-kqueue/src/test/java/io/netty/channel/kqueue
    • KQueueDomainSocketFdTest.java
  • transport/src
    • main
      • java/io/netty
        • bootstrap
          • AbstractBootstrap.java
          • Bootstrap.java
          • ServerBootstrap.java
        • channel
          • AbstractChannel.java
          • embedded
            • EmbeddedChannel.java
          • pool
            • AbstractChannelPoolMap.java
            • FixedChannelPool.java
            • SimpleChannelPool.java
      • resources/META-INF/native-image/io.netty/netty5-transport/generated/handlers
        • reflect-config.json
    • test/java/io/netty/channel
      • AbstractCoalescingBufferQueueTest.java
      • CoalescingBufferQueueTest.java
      • DefaultChannelPipelineTest.java
      • PendingWriteQueueTest.java
      • ReentrantChannelTest.java
      • SingleThreadEventLoopTest.java
      • embedded
        • EmbeddedChannelTest.java
      • local
        • LocalChannelTest.java
      • pool
        • AbstractChannelPoolMapTest.java
        • FixedChannelPoolTest.java
      • socket/nio
        • NioSocketChannelTest.java

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎codec-base/src/main/java/io/netty/handler/codec/MessageAggregator.java‎

Copy file name to clipboardExpand all lines: codec-base/src/main/java/io/netty/handler/codec/MessageAggregator.java
+3-6Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,9 @@ protected void decode(final ChannelHandlerContext ctx, I msg, List<Object> out)
223223
// Cache the write listener for reuse.
224224
ChannelFutureListener listener = continueResponseWriteListener;
225225
if (listener == null) {
226-
continueResponseWriteListener = listener = new ChannelFutureListener() {
227-
@Override
228-
public void operationComplete(ChannelFuture future) {
229-
if (!future.isSuccess()) {
230-
ctx.fireExceptionCaught(future.cause());
231-
}
226+
continueResponseWriteListener = listener = future -> {
227+
if (!future.isSuccess()) {
228+
ctx.fireExceptionCaught(future.cause());
232229
}
233230
};
234231
}
Collapse file

‎codec-compression/src/main/java/io/netty/handler/codec/compression/EncoderUtil.java‎

Copy file name to clipboardExpand all lines: codec-compression/src/main/java/io/netty/handler/codec/compression/EncoderUtil.java
+5-8Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,11 @@ public void run() {
3737
}
3838
}, THREAD_POOL_DELAY_SECONDS, TimeUnit.SECONDS);
3939

40-
finishFuture.addListener(new ChannelFutureListener() {
41-
@Override
42-
public void operationComplete(ChannelFuture f) {
43-
// Cancel the scheduled timeout.
44-
future.cancel(true);
45-
if (!promise.isDone()) {
46-
ctx.close(promise);
47-
}
40+
finishFuture.addListener(f -> {
41+
// Cancel the scheduled timeout.
42+
future.cancel(true);
43+
if (!promise.isDone()) {
44+
ctx.close(promise);
4845
}
4946
});
5047
} else {
Collapse file

‎codec-compression/src/main/java/io/netty/handler/codec/compression/JZlibEncoder.java‎

Copy file name to clipboardExpand all lines: codec-compression/src/main/java/io/netty/handler/codec/compression/JZlibEncoder.java
+5-8Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,11 @@ public void run() {
337337
}
338338
}, THREAD_POOL_DELAY_SECONDS, TimeUnit.SECONDS);
339339

340-
f.addListener(new ChannelFutureListener() {
341-
@Override
342-
public void operationComplete(ChannelFuture f) {
343-
// Cancel the scheduled timeout.
344-
future.cancel(true);
345-
if (!promise.isDone()) {
346-
ctx.close(promise);
347-
}
340+
f.addListener(f1 -> {
341+
// Cancel the scheduled timeout.
342+
future.cancel(true);
343+
if (!promise.isDone()) {
344+
ctx.close(promise);
348345
}
349346
});
350347
} else {
Collapse file

‎codec-compression/src/test/java/io/netty/handler/codec/compression/Lz4FrameEncoderTest.java‎

Copy file name to clipboardExpand all lines: codec-compression/src/test/java/io/netty/handler/codec/compression/Lz4FrameEncoderTest.java
+7-10Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -280,16 +280,13 @@ public void run() {
280280
final int size = 27;
281281
ByteBuf buf = ByteBufAllocator.DEFAULT.buffer(size, size);
282282
finalClientChannel.writeAndFlush(buf.writerIndex(buf.writerIndex() + size))
283-
.addListener(new ChannelFutureListener() {
284-
@Override
285-
public void operationComplete(ChannelFuture future) {
286-
try {
287-
writeFailCauseRef.set(future.cause());
288-
} finally {
289-
latch.countDown();
290-
}
291-
}
292-
});
283+
.addListener(future -> {
284+
try {
285+
writeFailCauseRef.set(future.cause());
286+
} finally {
287+
latch.countDown();
288+
}
289+
});
293290
}
294291
});
295292
latch.await();
Collapse file

‎codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectAggregator.java‎

Copy file name to clipboardExpand all lines: codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectAggregator.java
+8-15Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import io.netty.buffer.ByteBuf;
1919
import io.netty.buffer.Unpooled;
2020
import io.netty.channel.ChannelFuture;
21-
import io.netty.channel.ChannelFutureListener;
2221
import io.netty.channel.ChannelHandler;
2322
import io.netty.channel.ChannelHandlerContext;
2423
import io.netty.channel.ChannelPipeline;
@@ -249,23 +248,17 @@ protected void handleOversizedMessage(final ChannelHandlerContext ctx, HttpMessa
249248
if (oversized instanceof FullHttpMessage ||
250249
!HttpUtil.is100ContinueExpected(oversized) && !HttpUtil.isKeepAlive(oversized)) {
251250
ChannelFuture future = ctx.writeAndFlush(TOO_LARGE_CLOSE.retainedDuplicate());
252-
future.addListener(new ChannelFutureListener() {
253-
@Override
254-
public void operationComplete(ChannelFuture future) {
255-
if (!future.isSuccess()) {
256-
logger.debug("Failed to send a 413 Request Entity Too Large.", future.cause());
257-
}
258-
ctx.close();
251+
future.addListener(f -> {
252+
if (!f.isSuccess()) {
253+
logger.debug("Failed to send a 413 Request Entity Too Large.", f.cause());
259254
}
255+
ctx.close();
260256
});
261257
} else {
262-
ctx.writeAndFlush(TOO_LARGE.retainedDuplicate()).addListener(new ChannelFutureListener() {
263-
@Override
264-
public void operationComplete(ChannelFuture future) {
265-
if (!future.isSuccess()) {
266-
logger.debug("Failed to send a 413 Request Entity Too Large.", future.cause());
267-
ctx.close();
268-
}
258+
ctx.writeAndFlush(TOO_LARGE.retainedDuplicate()).addListener(future -> {
259+
if (!future.isSuccess()) {
260+
logger.debug("Failed to send a 413 Request Entity Too Large.", future.cause());
261+
ctx.close();
269262
}
270263
});
271264
}
Collapse file

‎codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker.java‎

Copy file name to clipboardExpand all lines: codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker.java
+32-44Lines changed: 32 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ public ChannelFuture handshake(Channel channel) {
287287
* the {@link ChannelPromise} to be notified when the opening handshake is sent
288288
*/
289289
public final ChannelFuture handshake(Channel channel, final ChannelPromise promise) {
290-
ChannelPipeline pipeline = channel.pipeline();
290+
final ChannelPipeline pipeline = channel.pipeline();
291291
HttpResponseDecoder decoder = pipeline.get(HttpResponseDecoder.class);
292292
if (decoder == null) {
293293
HttpClientCodec codec = pipeline.get(HttpClientCodec.class);
@@ -322,26 +322,22 @@ public final ChannelFuture handshake(Channel channel, final ChannelPromise promi
322322

323323
FullHttpRequest request = newHandshakeRequest();
324324

325-
channel.writeAndFlush(request).addListener(new ChannelFutureListener() {
326-
@Override
327-
public void operationComplete(ChannelFuture future) {
328-
if (future.isSuccess()) {
329-
ChannelPipeline p = future.channel().pipeline();
330-
ChannelHandlerContext ctx = p.context(HttpRequestEncoder.class);
331-
if (ctx == null) {
332-
ctx = p.context(HttpClientCodec.class);
333-
}
334-
if (ctx == null) {
335-
promise.setFailure(new IllegalStateException("ChannelPipeline does not contain " +
336-
"an HttpRequestEncoder or HttpClientCodec"));
337-
return;
338-
}
339-
p.addAfter(ctx.name(), "ws-encoder", newWebSocketEncoder());
340-
341-
promise.setSuccess();
342-
} else {
343-
promise.setFailure(future.cause());
325+
channel.writeAndFlush(request).addListener(future -> {
326+
if (future.isSuccess()) {
327+
ChannelHandlerContext ctx = pipeline.context(HttpRequestEncoder.class);
328+
if (ctx == null) {
329+
ctx = pipeline.context(HttpClientCodec.class);
344330
}
331+
if (ctx == null) {
332+
promise.setFailure(new IllegalStateException("ChannelPipeline does not contain " +
333+
"an HttpRequestEncoder or HttpClientCodec"));
334+
return;
335+
}
336+
pipeline.addAfter(ctx.name(), "ws-encoder", newWebSocketEncoder());
337+
338+
promise.setSuccess();
339+
} else {
340+
promise.setFailure(future.cause());
345341
}
346342
});
347343
return promise;
@@ -687,32 +683,24 @@ private ChannelFuture close0(final ChannelOutboundInvoker invoker, final Channel
687683
return promise;
688684
}
689685

690-
promise.addListener(new ChannelFutureListener() {
691-
@Override
692-
public void operationComplete(ChannelFuture future) {
693-
// If flush operation failed, there is no reason to expect
694-
// a server to receive CloseFrame. Thus this should be handled
695-
// by the application separately.
696-
// Also, close might be called twice from different threads.
697-
if (future.isSuccess() && channel.isActive() &&
698-
FORCE_CLOSE_INIT_UPDATER.compareAndSet(handshaker, 0, 1)) {
699-
final Future<?> forceCloseFuture = channel.executor().schedule(new Runnable() {
700-
@Override
701-
public void run() {
702-
if (channel.isActive()) {
703-
invoker.close();
704-
forceCloseComplete = true;
705-
}
686+
promise.addListener(future -> {
687+
// If flush operation failed, there is no reason to expect
688+
// a server to receive CloseFrame. Thus this should be handled
689+
// by the application separately.
690+
// Also, close might be called twice from different threads.
691+
if (future.isSuccess() && channel.isActive() &&
692+
FORCE_CLOSE_INIT_UPDATER.compareAndSet(handshaker, 0, 1)) {
693+
final Future<?> forceCloseFuture = channel.executor().schedule(new Runnable() {
694+
@Override
695+
public void run() {
696+
if (channel.isActive()) {
697+
invoker.close();
698+
forceCloseComplete = true;
706699
}
707-
}, forceCloseTimeoutMillis, TimeUnit.MILLISECONDS);
700+
}
701+
}, forceCloseTimeoutMillis, TimeUnit.MILLISECONDS);
708702

709-
channel.closeFuture().addListener(new ChannelFutureListener() {
710-
@Override
711-
public void operationComplete(ChannelFuture future) {
712-
forceCloseFuture.cancel(false);
713-
}
714-
});
715-
}
703+
channel.closeFuture().addListener(f -> forceCloseFuture.cancel(false));
716704
}
717705
});
718706
return promise;
Collapse file

‎codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientProtocolHandshakeHandler.java‎

Copy file name to clipboardExpand all lines: codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientProtocolHandshakeHandler.java
+8-18Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@
1616
package io.netty.handler.codec.http.websocketx;
1717

1818
import io.netty.channel.ChannelFuture;
19-
import io.netty.channel.ChannelFutureListener;
2019
import io.netty.channel.ChannelHandlerContext;
2120
import io.netty.channel.ChannelInboundHandler;
2221
import io.netty.channel.ChannelPromise;
2322
import io.netty.handler.codec.http.FullHttpResponse;
2423
import io.netty.handler.codec.http.websocketx.WebSocketClientProtocolHandler.ClientHandshakeStateEvent;
2524
import io.netty.util.concurrent.Future;
26-
import io.netty.util.concurrent.FutureListener;
2725

2826
import java.util.concurrent.TimeUnit;
2927

@@ -55,16 +53,13 @@ public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
5553
@Override
5654
public void channelActive(final ChannelHandlerContext ctx) throws Exception {
5755
ctx.fireChannelActive();
58-
handshaker.handshake(ctx.channel()).addListener(new ChannelFutureListener() {
59-
@Override
60-
public void operationComplete(ChannelFuture future) {
61-
if (!future.isSuccess()) {
62-
handshakePromise.tryFailure(future.cause());
63-
ctx.fireExceptionCaught(future.cause());
64-
} else {
65-
ctx.fireUserEventTriggered(
66-
WebSocketClientProtocolHandler.ClientHandshakeStateEvent.HANDSHAKE_ISSUED);
67-
}
56+
handshaker.handshake(ctx.channel()).addListener(future -> {
57+
if (!future.isSuccess()) {
58+
handshakePromise.tryFailure(future.cause());
59+
ctx.fireExceptionCaught(future.cause());
60+
} else {
61+
ctx.fireUserEventTriggered(
62+
ClientHandshakeStateEvent.HANDSHAKE_ISSUED);
6863
}
6964
});
7065
applyHandshakeTimeout();
@@ -125,12 +120,7 @@ public void run() {
125120
}, handshakeTimeoutMillis, TimeUnit.MILLISECONDS);
126121

127122
// Cancel the handshake timeout when handshake is finished.
128-
localHandshakePromise.addListener(new FutureListener<Void>() {
129-
@Override
130-
public void operationComplete(Future<Void> f) {
131-
timeoutFuture.cancel(false);
132-
}
133-
});
123+
localHandshakePromise.addListener(f -> timeoutFuture.cancel(false));
134124
}
135125

136126
/**
Collapse file

‎codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketProtocolHandler.java‎

Copy file name to clipboardExpand all lines: codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketProtocolHandler.java
+2-12Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,7 @@ public void close(final ChannelHandlerContext ctx, final ChannelPromise promise)
9999
}
100100
flush(ctx);
101101
applyCloseSentTimeout(ctx);
102-
closeSent.addListener(new ChannelFutureListener() {
103-
@Override
104-
public void operationComplete(ChannelFuture future) {
105-
ctx.close(promise);
106-
}
107-
});
102+
closeSent.addListener(future -> ctx.close(promise));
108103
}
109104
}
110105

@@ -139,12 +134,7 @@ public void run() {
139134
}
140135
}, forceCloseTimeoutMillis, TimeUnit.MILLISECONDS);
141136

142-
closeSent.addListener(new ChannelFutureListener() {
143-
@Override
144-
public void operationComplete(ChannelFuture future) {
145-
timeoutTask.cancel(false);
146-
}
147-
});
137+
closeSent.addListener(future -> timeoutTask.cancel(false));
148138
}
149139

150140
/**
Collapse file

‎codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker.java‎

Copy file name to clipboardExpand all lines: codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker.java
+7-10Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,13 @@ public final ChannelFuture handshake(Channel channel, FullHttpRequest req,
228228
encoderName = p.context(HttpResponseEncoder.class).name();
229229
p.addBefore(encoderName, "wsencoder", newWebSocketEncoder());
230230
}
231-
channel.writeAndFlush(response).addListener(new ChannelFutureListener() {
232-
@Override
233-
public void operationComplete(ChannelFuture future) {
234-
if (future.isSuccess()) {
235-
ChannelPipeline p = future.channel().pipeline();
236-
p.remove(encoderName);
237-
promise.setSuccess();
238-
} else {
239-
promise.setFailure(future.cause());
240-
}
231+
channel.writeAndFlush(response).addListener(future -> {
232+
if (future.isSuccess()) {
233+
ChannelPipeline p1 = channel.pipeline();
234+
p1.remove(encoderName);
235+
promise.setSuccess();
236+
} else {
237+
promise.setFailure(future.cause());
241238
}
242239
});
243240
return promise;
Collapse file

‎codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java‎

Copy file name to clipboardExpand all lines: codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java
+13-23Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package io.netty.handler.codec.http.websocketx;
1717

1818
import io.netty.channel.ChannelFuture;
19-
import io.netty.channel.ChannelFutureListener;
2019
import io.netty.channel.ChannelHandlerContext;
2120
import io.netty.channel.ChannelInboundHandler;
2221
import io.netty.channel.ChannelPipeline;
@@ -28,7 +27,6 @@
2827
import io.netty.handler.ssl.SslHandler;
2928
import io.netty.util.ReferenceCountUtil;
3029
import io.netty.util.concurrent.Future;
31-
import io.netty.util.concurrent.FutureListener;
3230

3331
import java.util.concurrent.TimeUnit;
3432

@@ -84,21 +82,18 @@ public void channelRead(final ChannelHandlerContext ctx, Object msg) throws Exce
8482
ctx.pipeline().remove(this);
8583

8684
final ChannelFuture handshakeFuture = handshaker.handshake(ctx.channel(), req);
87-
handshakeFuture.addListener(new ChannelFutureListener() {
88-
@Override
89-
public void operationComplete(ChannelFuture future) {
90-
if (!future.isSuccess()) {
91-
localHandshakePromise.tryFailure(future.cause());
92-
ctx.fireExceptionCaught(future.cause());
93-
} else {
94-
localHandshakePromise.trySuccess();
95-
// Kept for compatibility
96-
ctx.fireUserEventTriggered(
97-
WebSocketServerProtocolHandler.ServerHandshakeStateEvent.HANDSHAKE_COMPLETE);
98-
ctx.fireUserEventTriggered(
99-
new WebSocketServerProtocolHandler.HandshakeComplete(
100-
req.uri(), req.headers(), handshaker.selectedSubprotocol()));
101-
}
85+
handshakeFuture.addListener(future -> {
86+
if (!future.isSuccess()) {
87+
localHandshakePromise.tryFailure(future.cause());
88+
ctx.fireExceptionCaught(future.cause());
89+
} else {
90+
localHandshakePromise.trySuccess();
91+
// Kept for compatibility
92+
ctx.fireUserEventTriggered(
93+
ServerHandshakeStateEvent.HANDSHAKE_COMPLETE);
94+
ctx.fireUserEventTriggered(
95+
new WebSocketServerProtocolHandler.HandshakeComplete(
96+
req.uri(), req.headers(), handshaker.selectedSubprotocol()));
10297
}
10398
});
10499
applyHandshakeTimeout();
@@ -160,11 +155,6 @@ public void run() {
160155
}, handshakeTimeoutMillis, TimeUnit.MILLISECONDS);
161156

162157
// Cancel the handshake timeout when handshake is finished.
163-
localHandshakePromise.addListener(new FutureListener<Void>() {
164-
@Override
165-
public void operationComplete(Future<Void> f) {
166-
timeoutFuture.cancel(false);
167-
}
168-
});
158+
localHandshakePromise.addListener(f -> timeoutFuture.cancel(false));
169159
}
170160
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.