List of usage examples for io.netty.channel ChannelPromise unvoid
ChannelPromise unvoid();
From source file:io.grpc.netty.Http2ControlFrameLimitEncoder.java
License:Apache License
private ChannelPromise handleOutstandingControlFrames(ChannelHandlerContext ctx, ChannelPromise promise) { if (!limitReached) { if (outstandingControlFrames == maxOutstandingControlFrames) { // Let's try to flush once as we may be able to flush some of the control frames. ctx.flush();//from w w w.jav a 2 s . c om } if (outstandingControlFrames == maxOutstandingControlFrames) { limitReached = true; Http2Exception exception = Http2Exception.connectionError(Http2Error.ENHANCE_YOUR_CALM, "Maximum number %d of outstanding control frames reached", maxOutstandingControlFrames); logger.info("Maximum number {} of outstanding control frames reached. Closing channel {}", maxOutstandingControlFrames, ctx.channel(), exception); // First notify the Http2LifecycleManager and then close the connection. lifecycleManager.onError(ctx, true, exception); ctx.close(); } outstandingControlFrames++; // We did not reach the limit yet, add the listener to decrement the number of outstanding control frames // once the promise was completed return promise.unvoid().addListener(outstandingControlFramesListener); } return promise; }