Skip to content

Commit 0108a96

Browse files
brentschmaltzBrent SchmaltzHP712
authored
Add additional condition before requesting update. (#3095)
* Add additional condition before requesting update. * Add try catch in case telemetry methods throw. * fix indent --------- Co-authored-by: Brent Schmaltz <[email protected]> Co-authored-by: id4s <[email protected]>
1 parent 9e91a64 commit 0108a96

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -248,22 +248,41 @@ public virtual async Task<T> GetConfigurationAsync(CancellationToken cancel)
248248
{
249249
if (_refreshRequested)
250250
{
251-
// Log as manual because RequestRefresh was called
252-
TelemetryClient.IncrementConfigurationRefreshRequestCounter(
253-
MetadataAddress,
254-
TelemetryConstants.Protocols.Manual);
251+
_refreshRequested = false;
252+
253+
try
254+
{
255+
// Log as manual because RequestRefresh was called
256+
TelemetryClient.IncrementConfigurationRefreshRequestCounter(
257+
MetadataAddress,
258+
TelemetryConstants.Protocols.Manual);
259+
}
260+
#pragma warning disable CA1031 // Do not catch general exception types
261+
catch
262+
{ }
263+
#pragma warning restore CA1031 // Do not catch general exception types
255264

256265
UpdateCurrentConfiguration();
257-
_refreshRequested = false;
258266
}
259-
else
267+
else if (SyncAfter <= _timeProvider.GetUtcNow())
260268
{
261-
TelemetryClient.IncrementConfigurationRefreshRequestCounter(
262-
MetadataAddress,
263-
TelemetryConstants.Protocols.Automatic);
269+
try
270+
{
271+
TelemetryClient.IncrementConfigurationRefreshRequestCounter(
272+
MetadataAddress,
273+
TelemetryConstants.Protocols.Automatic);
274+
}
275+
#pragma warning disable CA1031 // Do not catch general exception types
276+
catch
277+
{ }
278+
#pragma warning restore CA1031 // Do not catch general exception types
264279

265280
_ = Task.Run(UpdateCurrentConfiguration, CancellationToken.None);
266281
}
282+
else
283+
{
284+
Interlocked.Exchange(ref _configurationRetrieverState, ConfigurationRetrieverIdle);
285+
}
267286
}
268287
}
269288

0 commit comments

Comments
 (0)