Extract the Consul default-context field as a constant (#1538)

pull/1362/merge
song 4 weeks ago committed by GitHub
parent 38b4faf9da
commit d77efe1f6b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -41,6 +41,8 @@ public class ConsulRefresherHandler extends AbstractConfigThreadPoolDynamicRefre
private static final int INITIAL_CAPACITY = 64;
private static final String DEFAULT_CONTEXT = "spring.cloud.consul.config.default-context";
@EventListener(EnvironmentChangeEvent.class)
public void refreshed(EnvironmentChangeEvent event) {
Map<String, Object> configInfo = extractLatestConfigInfo(event);
@ -70,7 +72,7 @@ public class ConsulRefresherHandler extends AbstractConfigThreadPoolDynamicRefre
private CharSequence getApplicationConfigDefaultContext(AbstractEnvironment environment) {
return environment.getPropertySources().stream()
.filter(propertySource -> propertySource instanceof OriginTrackedMapPropertySource)
.map(propertySource -> ((Map<String, CharSequence>) propertySource.getSource()).get("spring.cloud.consul.config.default-context"))
.map(propertySource -> ((Map<String, CharSequence>) propertySource.getSource()).get(DEFAULT_CONTEXT))
.findFirst().orElse(StringUtils.EMPTY);
}

Loading…
Cancel
Save