Class ChannelCloseUtils


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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void assignConnectionError​(io.netty.channel.Channel channel, java.lang.Throwable error)
      Assigns a Throwable to the passed Channel to report it as a closure reason.
      static java.lang.Throwable channelError​(io.netty.channel.Channel channel)
      Returns an error associated with the passed Channel.
      static io.netty.channel.ChannelFuture close​(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable error)
      Close the passed ChannelHandlerContext due to the observed error.
      static io.netty.channel.ChannelFuture close​(io.netty.channel.Channel channel, java.lang.Throwable error)
      Close the passed Channel due to the observed error.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • assignConnectionError

        public static void assignConnectionError​(io.netty.channel.Channel channel,
                                                 java.lang.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,
                                                           java.lang.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,
                                                           java.lang.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 java.lang.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