diff --git a/handler/src/main/java/io/netty/handler/ssl/SniHandler.java b/handler/src/main/java/io/netty/handler/ssl/SniHandler.java index 4cfe78145b0..56c98ef1834 100644 --- a/handler/src/main/java/io/netty/handler/ssl/SniHandler.java +++ b/handler/src/main/java/io/netty/handler/ssl/SniHandler.java @@ -57,7 +57,7 @@ public class SniHandler extends ByteToMessageDecoder implements ChannelOutboundH InternalLoggerFactory.getInstance(SniHandler.class); private static final Selection EMPTY_SELECTION = new Selection(null, null); - private final AsyncMapping mapping; + protected final AsyncMapping mapping; private boolean handshakeFailed; private boolean suppressRead; @@ -273,8 +273,8 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) t } } - private void select(final ChannelHandlerContext ctx, final String hostname) { - Future future = mapping.map(hostname, ctx.executor().newPromise()); + private void select(final ChannelHandlerContext ctx, final String hostname) throws Exception { + Future future = lookup(ctx, hostname); if (future.isDone()) { if (future.isSuccess()) { onSslContext(ctx, hostname, future.getNow()); @@ -305,6 +305,16 @@ public void operationComplete(Future future) throws Exception { } } + /** + * The default implementation will simply call {@link AsyncMapping#map(Object, Promise)} but + * users can override this method to implement custom behavior. + * + * @see AsyncMapping#map(Object, Promise) + */ + protected Future lookup(ChannelHandlerContext ctx, String hostname) throws Exception { + return mapping.map(hostname, ctx.executor().newPromise()); + } + /** * Called upon successful completion of the {@link AsyncMapping}'s {@link Future}. *