Skip to content

Commit c006ff4

Browse files
committed
Follow-up to #385
There is still a slim chance that the code in #385 will throw `InvalidOperationException`, since the check and call to `SetException` is not atomic. `ManualResetValueTaskSource` does not have `TrySetException` like `TaskCompletionSource`.
1 parent 14b6e2d commit c006ff4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

RabbitMQ.Stream.Client/Client.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -976,11 +976,13 @@ public bool RunContinuationsAsynchronously
976976
public void SetException(Exception error)
977977
{
978978
// https://github.com/rabbitmq/rabbitmq-stream-dotnet-client/issues/384
979-
// we need to check if the task is pending before setting the exception
980-
if (_logic.GetStatus(_logic.Version) == ValueTaskSourceStatus.Pending)
979+
try
981980
{
982981
_logic.SetException(error);
983982
}
983+
catch (InvalidOperationException)
984+
{
985+
}
984986
}
985987

986988
void IValueTaskSource.GetResult(short token) => _logic.GetResult(token);

0 commit comments

Comments
 (0)