@@ -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 }
0 commit comments