Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Polly.Core/Utils/CancellationTokenSourcePool.Pooled.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace Polly.Utils;
internal abstract partial class CancellationTokenSourcePool
{
#if NET6_0_OR_GREATER
private sealed class PooledCancellationTokenSourcePool : CancellationTokenSourcePool
internal sealed class PooledCancellationTokenSourcePool : CancellationTokenSourcePool
{
public static readonly PooledCancellationTokenSourcePool SystemInstance = new(TimeProvider.System);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ public void ArgValidation_Ok()
[Theory]
public void RentReturn_Reusable_EnsureProperBehavior(object timeProvider)
{
// Use a dedicated pool instance instead of CancellationTokenSourcePool.Create(...), which
// returns a process-wide shared singleton for TimeProvider.System. Using the shared singleton
// makes this test flaky, as other tests running in parallel can rent/return CancellationTokenSource
// instances from the same pool concurrently, changing which instance is returned by Get().
#if NET6_0_OR_GREATER
var pool = new CancellationTokenSourcePool.PooledCancellationTokenSourcePool(GetTimeProvider(timeProvider));
Comment thread
martincostello marked this conversation as resolved.
#else
var pool = CancellationTokenSourcePool.Create(GetTimeProvider(timeProvider));
#endif
var cts = pool.Get(System.Threading.Timeout.InfiniteTimeSpan);
pool.Return(cts);

Expand Down
Loading