Skip to content

Commit a87533a

Browse files
committed
Fixed propagation of the token
1 parent 214ff7d commit a87533a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/DotNext.Threading/Threading/Leases/LeaseConsumer.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,15 @@ public async Task<TResult> ExecuteAsync<TResult>(Func<CancellationToken, Task<TR
210210
{
211211
throw new AggregateException(exception, e);
212212
}
213-
catch (OperationCanceledException e) when (e.CausedBy(cts, leaseToken))
213+
catch (OperationCanceledException e) when (e.CancellationToken == leaseToken ||
214+
e.CancellationToken == cts?.Token && cts.CancellationOrigin == leaseToken)
214215
{
215216
throw new TimeoutException(ExceptionMessages.LeaseExpired, e);
216217
}
218+
catch (OperationCanceledException e) when (cts is not null)
219+
{
220+
throw new OperationCanceledException(e.Message, e, cts.CancellationOrigin);
221+
}
217222
finally
218223
{
219224
cts?.Dispose();

0 commit comments

Comments
 (0)