Skip to content

Commit a141380

Browse files
Resolve comments
1 parent fdaa51f commit a141380

File tree

3 files changed

+11
-47
lines changed

3 files changed

+11
-47
lines changed

src/Microsoft.Extensions.Configuration.AzureAppConfiguration/ConfigurationClientManager.cs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,11 @@ public IEnumerable<ConfigurationClient> GetAvailableClients()
126126
_ = DiscoverFallbackClients();
127127
}
128128

129-
List<ConfigurationClient> clients = new List<ConfigurationClient>(_clients.Where(c => c.BackoffEndTime <= now).Select(c => c.Client));
129+
IEnumerable<ConfigurationClient> clients = _clients.Where(c => c.BackoffEndTime <= now).Select(c => c.Client);
130130

131-
if (_dynamicClients != null)
131+
if (_dynamicClients != null && _dynamicClients.Any())
132132
{
133-
foreach (ConfigurationClientWrapper client in _dynamicClients)
134-
{
135-
if (client.BackoffEndTime <= now)
136-
{
137-
clients.Add(client.Client);
138-
}
139-
}
133+
clients = clients.Concat(_dynamicClients.Where(c => c.BackoffEndTime <= now).Select(c => c.Client));
140134
}
141135

142136
return clients;
@@ -151,16 +145,13 @@ public IEnumerable<ConfigurationClient> GetAllClients()
151145
_lastFallbackClientRefreshAttempt = now;
152146

153147
_ = DiscoverFallbackClients();
154-
}
148+
}
149+
150+
IEnumerable<ConfigurationClient> clients = _clients.Select(c => c.Client);
155151

156-
List<ConfigurationClient> clients = new List<ConfigurationClient>(_clients.Select(c => c.Client));
157-
158-
if (_dynamicClients != null)
152+
if (_dynamicClients != null && _dynamicClients.Any())
159153
{
160-
foreach (ConfigurationClientWrapper client in _dynamicClients)
161-
{
162-
clients.Add(client.Client);
163-
}
154+
clients = clients.Concat(_dynamicClients.Select(c => c.Client));
164155
}
165156

166157
return clients;
@@ -263,7 +254,7 @@ private async Task DiscoverFallbackClients()
263254
{
264255
await RefreshFallbackClients(cts.Token).ConfigureAwait(false);
265256
}
266-
catch (OperationCanceledException e)
257+
catch (OperationCanceledException e) when (!_cancellationTokenSource.IsCancellationRequested)
267258
{
268259
_logger.LogWarning(LogHelper.BuildFallbackClientLookupFailMessage(e.Message));
269260
}

src/Microsoft.Extensions.Configuration.AzureAppConfiguration/Extensions/TaskExtensions.cs

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/Microsoft.Extensions.Configuration.AzureAppConfiguration/SrvLookupClient.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,14 @@ public async Task<IEnumerable<SrvRecord>> QueryAsync(string host, CancellationTo
4848

4949
IEnumerable<SrvRecord> records = await InternalQueryAsync(altSrvDns, cancellationToken).ConfigureAwait(false);
5050

51-
if (records == null)
51+
// If we get no record from _alt{i} SRV, we have reached the end of _alt* list
52+
if (records == null || !records.Any())
5253
{
5354
break;
5455
}
5556

5657
results = results.Concat(records);
5758

58-
// If we get no record from _alt{i} SRV, we have reached the end of _alt* list
59-
if (records.Count() == 0)
60-
{
61-
break;
62-
}
63-
6459
index++;
6560
}
6661

0 commit comments

Comments
 (0)