in zuul-core/src/main/java/com/netflix/netty/common/Http2ConnectionCloseHandler.java [115:151]
private void closeChannel(ChannelHandlerContext ctx, ChannelPromise promise) {
Channel child = ctx.channel();
Channel parent = HttpUtils.getMainChannel(ctx);
// 1. Check if already_closing flag on this stream channel. If there is, then success this promise and return.
// If not, then add already_closing flag to this stream channel.
// 2. Check if already_closing flag on the parent channel.
// If so, then just return.
// If not, then set already_closing on parent channel, and then allow through.
if (isAlreadyClosing(child)) {
promise.setSuccess();
return;
}
if (isAlreadyClosing(parent)) {
return;
}
// Close according to the specified close type.
ConnectionCloseType closeType = ConnectionCloseType.fromChannel(parent);
Integer port =
parent.attr(SourceAddressChannelHandler.ATTR_SERVER_LOCAL_PORT).get();
port = port == null ? -1 : port;
incrementCounter(closeType, port);
switch (closeType) {
case DELAYED_GRACEFUL:
gracefullyWithDelay(ctx.executor(), parent, promise);
break;
case GRACEFUL:
case IMMEDIATE:
immediate(parent, promise);
break;
default:
throw new IllegalArgumentException("Unknown ConnectionCloseEvent type! - " + closeType);
}
}