Skip to content

Commit d8429a4

Browse files
committed
Use try / finally when returning buffers.
1 parent 6acbf12 commit d8429a4

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

projects/RabbitMQ.Client/client/impl/ChannelBase.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -431,17 +431,22 @@ private async Task HandleCommandAsync(IncomingCommand cmd, CancellationToken can
431431
*
432432
* Else, the incoming command is the return of an RPC call, and must be handled.
433433
*/
434-
if (false == await DispatchCommandAsync(cmd, cancellationToken)
435-
.ConfigureAwait(false))
434+
try
436435
{
437-
using (IRpcContinuation c = _continuationQueue.Next())
436+
if (false == await DispatchCommandAsync(cmd, cancellationToken)
437+
.ConfigureAwait(false))
438438
{
439-
await c.HandleCommandAsync(cmd)
440-
.ConfigureAwait(false);
439+
using (IRpcContinuation c = _continuationQueue.Next())
440+
{
441+
await c.HandleCommandAsync(cmd)
442+
.ConfigureAwait(false);
443+
}
441444
}
442445
}
443-
444-
cmd.ReturnBuffers();
446+
finally
447+
{
448+
cmd.ReturnBuffers();
449+
}
445450
}
446451

447452
[MethodImpl(MethodImplOptions.AggressiveInlining)]

0 commit comments

Comments
 (0)