Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid repeated calls to getState in AbstractDependentConfig #732

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.netflix.archaius.config;

import com.netflix.archaius.api.Config;
import com.netflix.archaius.api.PropertyDetails;

import java.util.Iterator;
Expand Down Expand Up @@ -27,9 +28,11 @@ public AbstractDependentConfig() {

@Override
public Object getRawProperty(String key) {
Object value = getState().getData().get(key);
if (getState().getInstrumentedKeys().containsKey(key)) {
getState().getInstrumentedKeys().get(key).recordUsage(createPropertyDetails(key, value));
CachedState state = getState();
Object value = state.getData().get(key);
Config config = state.getInstrumentedKeys().get(key);
if (config != null) {
config.recordUsage(createPropertyDetails(key, value));
}
return value;
}
Expand All @@ -52,9 +55,11 @@ public Iterable<String> keys() {

@Override
public void forEachProperty(BiConsumer<String, Object> consumer) {
getState().getData().forEach((k, v) -> {
if (getState().getInstrumentedKeys().containsKey(k)) {
getState().getInstrumentedKeys().get(k).recordUsage(createPropertyDetails(k, v));
CachedState state = getState();
state.getData().forEach((k, v) -> {
Config config = state.getInstrumentedKeys().get(k);
if (config != null) {
config.recordUsage(createPropertyDetails(k, v));
}
consumer.accept(k, v);
});
Expand All @@ -77,8 +82,10 @@ public boolean isEmpty() {

@Override
public void recordUsage(PropertyDetails propertyDetails) {
if (getState().getInstrumentedKeys().containsKey(propertyDetails.getKey())) {
getState().getInstrumentedKeys().get(propertyDetails.getKey()).recordUsage(createPropertyDetails(propertyDetails.getKey(), propertyDetails.getValue()));
CachedState state = getState();
Config config = state.getInstrumentedKeys().get(propertyDetails.getKey());
if (config != null) {
config.recordUsage(createPropertyDetails(propertyDetails.getKey(), propertyDetails.getValue()));
}
}

Expand Down
Loading