Context
We use feature hub to manage feature toggles
Also, we have 2 additional point
- not all feature toggles exist in feature hub, the responsible person often creates it when feature toggle is needed
- we have several feature toggle sources with priority, for example, feature hub, application properties, environment, etc
Issue
|
public FeatureState getFeatureState(String key) { |
|
return features.computeIfAbsent( |
|
key, |
|
key1 -> { |
|
if (hasReceivedInitialState) { |
|
log.error( |
|
"FeatureHub error: application requesting use of invalid key after initialization: `{}`", |
|
key1); |
|
} |
|
|
|
return new FeatureStateBase(null, this, key); |
|
}); |
|
} |
When we try to get feature value in java (io.featurehub.client.ClientFeatureRepository#getFeatureState) first time, then we have such log for our applications FeatureHub error: application requesting use of invalid key after initialization: XXX.
This happens only for the first request for the feature toggle (not existing in feature hub), after instance of application was restarted (because of java.util.Map#computeIfAbsent used)
So in monitoring of our applications we have error cases by logs
Fix
Idea how to fix #34
Context
We use feature hub to manage feature toggles
Also, we have 2 additional point
Issue
featurehub-java-sdk/client-java-core/src/main/java/io/featurehub/client/ClientFeatureRepository.java
Lines 247 to 259 in f6fd04b
When we try to get feature value in java (io.featurehub.client.ClientFeatureRepository#getFeatureState) first time, then we have such log for our applications
FeatureHub error: application requesting use of invalid key after initialization: XXX.This happens only for the first request for the feature toggle (not existing in feature hub), after instance of application was restarted (because of java.util.Map#computeIfAbsent used)
So in monitoring of our applications we have error cases by logs
Fix
Idea how to fix #34