Skip to content

Commit

Permalink
Fix - Don't error when using infinte connect timeout and Entra auth (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Engel committed Jul 8, 2024
1 parent bad621f commit a34ec48
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ public override async Task<SqlAuthenticationToken> AcquireTokenAsync(SqlAuthenti
using CancellationTokenSource cts = new();

// Use Connection timeout value to cancel token acquire request after certain period of time.
cts.CancelAfter(parameters.ConnectionTimeout * 1000); // Convert to milliseconds
int timeout = parameters.ConnectionTimeout * 1000; // Convert to milliseconds
if (timeout > 0) // if ConnectionTimeout is 0 or the millis overflows an int, no need to set CancelAfter
{
cts.CancelAfter(timeout);
}

string scope = parameters.Resource.EndsWith(s_defaultScopeSuffix, StringComparison.Ordinal) ? parameters.Resource : parameters.Resource + s_defaultScopeSuffix;
string[] scopes = new string[] { scope };
Expand Down

0 comments on commit a34ec48

Please sign in to comment.