From 37d4b5a2f79be5e200fa04a6744292877afd05c1 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Tue, 6 Jul 2021 16:43:27 +0200 Subject: [PATCH] Call fireUserEventTriggered(...) before we try to modify the pipeline Motivation: We should call fireUserEventTriggered(...) before we try to modify the pipeline as otherwise we may end up in the situation that the handler was already removed. Modifications: Change ordering of calls Result: Test pass again --- .../handler/ssl/ApplicationProtocolNegotiationHandler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/handler/src/main/java/io/netty/handler/ssl/ApplicationProtocolNegotiationHandler.java b/handler/src/main/java/io/netty/handler/ssl/ApplicationProtocolNegotiationHandler.java index 7f0b4c17b8..266bfd8de3 100644 --- a/handler/src/main/java/io/netty/handler/ssl/ApplicationProtocolNegotiationHandler.java +++ b/handler/src/main/java/io/netty/handler/ssl/ApplicationProtocolNegotiationHandler.java @@ -117,6 +117,9 @@ public abstract class ApplicationProtocolNegotiationHandler implements ChannelHa @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof SslHandshakeCompletionEvent) { + // Let's first fire the event before we try to modify the pipeline. + ctx.fireUserEventTriggered(evt); + SslHandshakeCompletionEvent handshakeEvent = (SslHandshakeCompletionEvent) evt; try { if (handshakeEvent.isSuccess()) { @@ -137,7 +140,6 @@ public abstract class ApplicationProtocolNegotiationHandler implements ChannelHa } catch (Throwable cause) { exceptionCaught(ctx, cause); } finally { - ctx.fireUserEventTriggered(evt); // Handshake failures are handled in exceptionCaught(...). if (handshakeEvent.isSuccess()) { removeSelfIfPresent(ctx);