File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed
src/OpenFeature.Contrib.Providers.AwsAppConfig Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -95,15 +95,27 @@ public async Task<GetLatestConfigurationResponse>GetLatestConfigurationAsync(Fea
9595 ConfigurationToken = await GetSessionToken ( profile )
9696 } ;
9797
98- var response = await _appConfigDataClient . GetLatestConfigurationAsync ( configurationRequest ) ;
98+ GetLatestConfigurationResponse response ;
9999
100- // If not NextPollConfigurationToken, something wrong with AWS connection.
101- if ( string . IsNullOrWhiteSpace ( response . NextPollConfigurationToken ) ) throw new Exception ( "Unable to connect to AWS" ) ;
100+ try
101+ {
102+ response = await _appConfigDataClient . GetLatestConfigurationAsync ( configurationRequest ) ;
103+ }
104+ catch
105+ {
106+ // On exception, could be because of connection issue or
107+ // too frequent call per defined by polling duration, get what's in cache
108+ response = null ;
109+ }
102110
103- // First, update the session token to the newly returned token
104- _memoryCache . Set ( sessionKey , response . NextPollConfigurationToken ) ;
111+ // Update Next Poll configuration token only when one is available.
112+ if ( response != null )
113+ {
114+ // First, update the session token to the newly returned token
115+ _memoryCache . Set ( sessionKey , response . NextPollConfigurationToken ) ;
116+ }
105117
106- if ( ( response . Configuration == null || response . Configuration . Length == 0 )
118+ if ( ( response ? . Configuration == null || response . Configuration . Length == 0 )
107119 && _memoryCache . TryGetValue ( configKey , out GetLatestConfigurationResponse configValue ) )
108120 {
109121 // AppConfig returns empty Configuration if value hasn't changed from last retrieval, hence use what's in cache.
You can’t perform that action at this time.
0 commit comments