public void ReleaseAndFailAll()
        {
            writeQueue.Add(cat, catPromise);
            writeQueue.Add(mouse, NewFutureListener());
            var cause = new Exception("ooops");

            writeQueue.ReleaseAndFailAll(cause);
            IPromise aggregatePromise = NewPromise();

            AssertQueueSize(0, true);
            Assert.Equal(0, cat.ReferenceCount);
            Assert.Equal(0, mouse.ReferenceCount);
            Assert.Same(cause, catPromise.Task.Exception.InnerException);
            Assert.Equal("", Dequeue(int.MaxValue, aggregatePromise));
            AssertQueueSize(0, true);
        }
 public override void Error(IChannelHandlerContext ctx, Exception cause)
 {
     _queue.ReleaseAndFailAll(cause);
     // Don't update dataSize because we need to ensure the size() method returns a consistent size even after
     // error so we don't invalidate flow control when returning bytes to flow control.
     //
     // That said we will set dataSize and padding to 0 in the write(...) method if we cleared the queue
     // because of an error.
     _owner._lifecycleManager.OnError(ctx, true, cause);
 }