-
Notifications
You must be signed in to change notification settings - Fork 98
Description
Expected Behaviour
If AppConfig returns an empty response (indicating that there have been no changes to the config since the last call to GetLatestConfiguration), then the provider should continue to return the cached version of the config.
Current Behaviour
As per the issue raised on v1 of the app, v2 is not correctly handling the empty response.
If an empty response is retrieved from AppConfig then null is returned which causes any transformer or, ultimately, the calling code to fail.
It seems the PR that was raised to fix the problem in v1 was not migrated to v2.
Code snippet
var provider = AppConfigProvider.builder()
.withClient(appConfigDataClient)
.withEnvironment(environmentVariables.getAppConfigEnvironment())
.withApplication(environmentVariables.getAppConfigApplication())
.build();
...
// Works fine on first call, but subsequent calls return `null`
var config = provider
provider
.withMaxAge(getConfigurationCacheTtl(), ChronoUnit.SECONDS)
.withTransformation(ConfigTransformer.class)
.get("test", Config.class);Possible Solution
See PR #1673
Steps to Reproduce
- Setup a freeform configuration profile in AppConfig with some value (we used a JSON object
{ "version": 1 }) - Retrieve from a lambda using PowerTools parameters:
var config = ParamManager.getAppConfigProvider("test", "test")
.withMaxAge(30, ChronoUnit.SECONDS)
.get("test");- Fire continuous traffic at the lambda
The first retrieval, on any given runtime environment, will work fine, but after the 30 second TTL the next retrieve from AppConfg returns an empty string, which is returned from the get() method rather than original (cached value).
Powertools for AWS Lambda (Java) version
2.2.0 (latest)
AWS Lambda function runtime
Java 17
Debugging logs
Metadata
Metadata
Assignees
Labels
Type
Projects
Status