File tree 1 file changed +18
-6
lines changed
src/OpenFeature.Contrib.Providers.AwsAppConfig
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
95
95
ConfigurationToken = await GetSessionToken ( profile )
96
96
} ;
97
97
98
- var response = await _appConfigDataClient . GetLatestConfigurationAsync ( configurationRequest ) ;
98
+ GetLatestConfigurationResponse response ;
99
99
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
+ }
102
110
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
+ }
105
117
106
- if ( ( response . Configuration == null || response . Configuration . Length == 0 )
118
+ if ( ( response ? . Configuration == null || response . Configuration . Length == 0 )
107
119
&& _memoryCache . TryGetValue ( configKey , out GetLatestConfigurationResponse configValue ) )
108
120
{
109
121
// 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