io.netty.handler.codec.http2.StreamBufferingEncoder.Http2ChannelClosedException Java Examples

The following examples show how to use io.netty.handler.codec.http2.StreamBufferingEncoder.Http2ChannelClosedException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NettyClientTransport.java    From grpc-nebula-java with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #2
Source File: NettyClientTransport.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}