Skip to content

Commit

Permalink
Merge pull request payara#5129 from poikilotherm/5126-mpconfig-msg
Browse files Browse the repository at this point in the history
feature(config-api): Make MPCONFIG in TranslatedConfigView debugable / FISH-1079
  • Loading branch information
Alan authored Feb 24, 2021
2 parents fe89b1f + 86f7332 commit 0e01683
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

import com.sun.enterprise.security.store.DomainScopedPasswordAliasStore;
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigValue;
import org.eclipse.microprofile.config.spi.ConfigProviderResolver;
import org.glassfish.hk2.api.ServiceLocator;
import org.jvnet.hk2.config.ConfigBeanProxy;
Expand Down Expand Up @@ -146,13 +147,17 @@ private static Object getTranslatedValue(Object value) {
String matchValue = envValue[0];
String defaultValue = envValue.length > 1 ? envValue[1] : null;
Config config = configResolver().getConfig();
Optional<String> newValue = config.getOptionalValue(matchValue, String.class);
if (newValue != null && newValue.isPresent()) {
stringValue = m3.replaceFirst(Matcher.quoteReplacement(m3.group(1) + newValue.get() + m3.group(3)));
ConfigValue configValue = config.getConfigValue(matchValue);
String newValue = configValue.getValue();
if (newValue != null && !newValue.isEmpty()) {
stringValue = m3.replaceFirst(Matcher.quoteReplacement(m3.group(1) + newValue + m3.group(3)));
m3.reset(stringValue);
Logger.getAnonymousLogger().fine("Found property '" + matchValue + "' in source '" + configValue.getSourceName() + "' with ordinal '" + configValue.getSourceOrdinal() + "'");
} else if (defaultValue != null) {
stringValue = defaultValue;
break;
} else {
Logger.getAnonymousLogger().warning("MicroProfile Config: property '" + matchValue + "': no value found, no default given.");
}
i++;
}
Expand Down

0 comments on commit 0e01683

Please sign in to comment.