类 io.netty.handler.codec.http2.StreamBufferingEncoder.Http2ChannelClosedException 源码实例Demo

下面列出了怎么用 io.netty.handler.codec.http2.StreamBufferingEncoder.Http2ChannelClosedException 的API类实例代码及写法,或者点击链接到github查看源代码。


/**
 * Convert ChannelFuture.cause() to a Status, taking into account that all handlers are removed
 * from the pipeline when the channel is closed. Since handlers are removed, you may get an
 * unhelpful exception like ClosedChannelException.
 *
 * <p>This method must only be called on the event loop.
 */
private Status statusFromFailedFuture(ChannelFuture f) {
  Throwable t = f.cause();
  if (t instanceof ClosedChannelException
      // Exception thrown by the StreamBufferingEncoder if the channel is closed while there
      // are still streams buffered. This exception is not helpful. Replace it by the real
      // cause of the shutdown (if available).
      || t instanceof Http2ChannelClosedException) {
    Status shutdownStatus = lifecycleManager.getShutdownStatus();
    if (shutdownStatus == null) {
      return Status.UNKNOWN.withDescription("Channel closed but for unknown reason")
          .withCause(new ClosedChannelException().initCause(t));
    }
    return shutdownStatus;
  }
  return Utils.statusFromThrowable(t);
}
 
源代码2 项目: grpc-java   文件: NettyClientTransport.java

/**
 * Convert ChannelFuture.cause() to a Status, taking into account that all handlers are removed
 * from the pipeline when the channel is closed. Since handlers are removed, you may get an
 * unhelpful exception like ClosedChannelException.
 *
 * <p>This method must only be called on the event loop.
 */
private Status statusFromFailedFuture(ChannelFuture f) {
  Throwable t = f.cause();
  if (t instanceof ClosedChannelException
      // Exception thrown by the StreamBufferingEncoder if the channel is closed while there
      // are still streams buffered. This exception is not helpful. Replace it by the real
      // cause of the shutdown (if available).
      || t instanceof Http2ChannelClosedException) {
    Status shutdownStatus = lifecycleManager.getShutdownStatus();
    if (shutdownStatus == null) {
      return Status.UNKNOWN.withDescription("Channel closed but for unknown reason")
          .withCause(new ClosedChannelException().initCause(t));
    }
    return shutdownStatus;
  }
  return Utils.statusFromThrowable(t);
}
 
 类方法
 同包方法