Fire SniCompletionEvent after onLookupComplete(...) was called (#10688)

Motivation:

Users may want to do special actions when onComplete(...) was called and depend on these once they receive the SniCompletionEvent

Modifications:

Switch order and so call onLookupComplete(...) before we fire the event

Result:

Fixes https://github.com/netty/netty/issues/10655
This commit is contained in:
Norman Maurer 2020-10-15 21:01:03 +02:00 committed by GitHub
parent 6b613682ba
commit 0ed788c15e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -128,8 +128,11 @@ public abstract class AbstractSniHandler<T> extends SslClientHelloHandler<T> {
@Override @Override
protected void onLookupComplete(ChannelHandlerContext ctx, Future<T> future) throws Exception { protected void onLookupComplete(ChannelHandlerContext ctx, Future<T> future) throws Exception {
fireSniCompletionEvent(ctx, hostname, future); try {
onLookupComplete(ctx, hostname, future); onLookupComplete(ctx, hostname, future);
} finally {
fireSniCompletionEvent(ctx, hostname, future);
}
} }
/** /**
@ -148,7 +151,7 @@ public abstract class AbstractSniHandler<T> extends SslClientHelloHandler<T> {
protected abstract void onLookupComplete(ChannelHandlerContext ctx, protected abstract void onLookupComplete(ChannelHandlerContext ctx,
String hostname, Future<T> future) throws Exception; String hostname, Future<T> future) throws Exception;
private void fireSniCompletionEvent(ChannelHandlerContext ctx, String hostname, Future<T> future) { private static void fireSniCompletionEvent(ChannelHandlerContext ctx, String hostname, Future<?> future) {
Throwable cause = future.cause(); Throwable cause = future.cause();
if (cause == null) { if (cause == null) {
ctx.fireUserEventTriggered(new SniCompletionEvent(hostname)); ctx.fireUserEventTriggered(new SniCompletionEvent(hostname));