Fix configuration properties in refresh scope for Boot 2.0

The old hack in RefreshScope has been replaced with a new hack.
It has to "reset" the ConfigurationProperties bean post processor
and the new rebinder API has changed the internals of that, so
we needed to adjust.
This commit is contained in:
Dave Syer
2017-09-29 13:44:38 +01:00
parent 1829d370ba
commit 9639787b03
4 changed files with 27 additions and 51 deletions

View File

@@ -27,6 +27,7 @@ import org.springframework.context.ApplicationContextAware;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.core.Ordered;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.util.ReflectionUtils;
@@ -151,7 +152,8 @@ public class RefreshScope extends GenericScope
try {
ConfigurationPropertiesBindingPostProcessor processor = context
.getBean(ConfigurationPropertiesBindingPostProcessor.class);
setField(processor, "propertySources", null);
setField(processor, "propertySources", ((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources());
setField(processor, "configurationPropertiesBinder", null);
processor.afterPropertiesSet();
}
catch (Exception e) {