dd-willgan commented on code in PR #10785:
URL: https://github.com/apache/pinot/pull/10785#discussion_r1200790730
##########
pinot-spi/src/main/java/org/apache/pinot/spi/env/CommonsConfigurationUtils.java:
##########
@@ -119,8 +120,56 @@ public static Map<String, Object> toMap(Configuration
configuration) {
}
private static Object mapValue(String key, Configuration configuration) {
- return Optional.of(configuration.getStringArray(key)).filter(values ->
values.length > 1).<Object>map(
- values -> Arrays.stream(values).collect(Collectors.joining(",")))
- .orElseGet(() -> configuration.getProperty(key));
+ // For multi-value config, convert it to a single comma connected string
value.
+ // For single-value config, return its raw property, unless it needs
interpolation.
+ return Optional.of(configuration.getStringArray(key)).filter(values ->
values.length > 1)
+ .<Object>map(values ->
Arrays.stream(values).collect(Collectors.joining(","))).orElseGet(() -> {
+ Object rawProperty = configuration.getProperty(key);
+ if (!needInterpolate(rawProperty)) {
+ return rawProperty;
+ }
+ // The string value is converted to the requested type when
accessing it via PinotConfiguration.
+ return configuration.getString(key);
+ });
+ }
+
+ public static boolean needInterpolate(Object rawProperty) {
+ if (rawProperty instanceof String) {
+ String strProperty = (String) rawProperty;
+ // e.g. if config value is '${sys:ENV_VAR_FOO}', it's replaced by value
of env var ENV_VAR_FOO.
Review Comment:
`${env:ENV_VAR_FOO}` would be replaced by env var ENV_VAR_FOO?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]