Skip to content

Commit 2c98773

Browse files
authored
Merge pull request #717 from Netflix/1.x-bridge-uninstrumented
Add getPropertiesUninstrumented endpoint for ConfigurationUtils
2 parents b74bd03 + 81e53ca commit 2c98773

2 files changed

Lines changed: 36 additions & 13 deletions

File tree

archaius-core/src/main/java/com/netflix/config/util/ConfigurationUtils.java

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,36 @@ public static Map<String, Configuration> getAllNamedConfiguration(Configuration
123123
* @return properties extracted from the configuration
124124
*/
125125
public static Properties getProperties(Configuration config) {
126-
Properties p = new Properties();
127-
if (config != null){
128-
Iterator<String> it = config.getKeys();
129-
while (it.hasNext()){
130-
String key = it.next();
131-
if (key != null) {
132-
Object value = config.getProperty(key);
133-
if (value != null) {
134-
p.put(key, value);
135-
} }
136-
}
137-
}
138-
return p;
126+
return getPropertiesInternal(config, true);
127+
}
128+
129+
/**
130+
* If possible, returns the Properties while avoiding instrumented fast property usage endpoints.
131+
* @param config Configuration to get the properties
132+
* @return properties extracted from the configuration
133+
*/
134+
public static Properties getPropertiesUninstrumented(Configuration config) {
135+
return getPropertiesInternal(config, false);
136+
}
137+
138+
private static Properties getPropertiesInternal(Configuration config, boolean instrumented) {
139+
Properties p = new Properties();
140+
if (config != null){
141+
Iterator<String> it = config.getKeys();
142+
while (it.hasNext()){
143+
String key = it.next();
144+
if (key != null) {
145+
Object value =
146+
!instrumented && config instanceof InstrumentationAware
147+
? ((InstrumentationAware) config).getPropertyUninstrumented(key)
148+
: config.getProperty(key);
149+
if (value != null) {
150+
p.put(key, value);
151+
}
152+
}
153+
}
154+
}
155+
return p;
139156
}
140157

141158
public static void loadProperties(Properties props, Configuration config) {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.netflix.config.util;
2+
3+
// Interface which surfaces instrumentation-related endpoints for configurations
4+
public interface InstrumentationAware {
5+
Object getPropertyUninstrumented(String key);
6+
}

0 commit comments

Comments
 (0)