Class ChannelCloseUtils

java.lang.Object
io.servicetalk.transport.netty.internal.ChannelCloseUtils

public final class ChannelCloseUtils extends Object
Utilities to handle Channel closure and its reason.
  • Method Details

    • assignConnectionError

      public static void assignConnectionError(io.netty.channel.Channel channel, Throwable error)
      Assigns a Throwable to the passed Channel to report it as a closure reason.
      Parameters:
      channel - a Channel to assign a Throwable to
      error - a Throwable
    • close

      public static io.netty.channel.ChannelFuture close(io.netty.channel.Channel channel, Throwable error)
      Close the passed Channel due to the observed error.
      Parameters:
      channel - a Channel to close
      error - a error that leads to the Channel closure
      Returns:
      ChannelFuture that will be notified once the operation completes
    • close

      public static io.netty.channel.ChannelFuture close(io.netty.channel.ChannelHandlerContext ctx, Throwable error)
      Close the passed ChannelHandlerContext due to the observed error.
      Parameters:
      ctx - a ChannelHandlerContext to close
      error - a error that leads to the ChannelHandlerContext closure
      Returns:
      ChannelFuture that will be notified once the operation completes
    • channelError

      @Nullable public static Throwable channelError(io.netty.channel.Channel channel)
      Returns an error associated with the passed Channel.
      Parameters:
      channel - to look for a Throwable
      Returns:
      an error associated with the passed Channel