Update to fix issues introduced in Boot 2.0.0.M1

This commit is contained in:
Dave Syer
2017-05-16 18:16:14 +01:00
parent 021a77d997
commit 3f005ab238
4 changed files with 14 additions and 9 deletions

View File

@@ -62,7 +62,7 @@ public class ConfigurationPropertiesRebinder
private ApplicationContext applicationContext;
private Map<String, Exception> errors = new ConcurrentHashMap<>();
private boolean resetting = false;
public ConfigurationPropertiesRebinder(
@@ -129,7 +129,7 @@ public class ConfigurationPropertiesRebinder
private void resetBinder() {
try {
setField(binder, "binder", null);
setField(binder, "propertySources", null);
binder.afterPropertiesSet();
}
catch (Exception e) {

View File

@@ -9,6 +9,7 @@ import java.util.Map;
import java.util.Set;
import org.springframework.boot.Banner.Mode;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.config.ConfigFileApplicationListener;
import org.springframework.cloud.bootstrap.BootstrapApplicationListener;
@@ -65,7 +66,8 @@ public class ContextRefresher {
StandardEnvironment environment = copyEnvironment(
this.context.getEnvironment());
SpringApplicationBuilder builder = new SpringApplicationBuilder(Empty.class)
.bannerMode(Mode.OFF).web(false).environment(environment);
.bannerMode(Mode.OFF).web(WebApplicationType.NONE)
.environment(environment);
// Just the listeners that affect the environment (e.g. excluding logging
// listener because it has side effects)
builder.application()

View File

@@ -151,7 +151,7 @@ public class RefreshScope extends GenericScope
try {
ConfigurationPropertiesBindingPostProcessor processor = context
.getBean(ConfigurationPropertiesBindingPostProcessor.class);
setField(processor, "binder", null);
setField(processor, "propertySources", null);
processor.afterPropertiesSet();
}
catch (Exception e) {

View File

@@ -21,6 +21,7 @@ import javax.servlet.ServletException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -61,18 +62,20 @@ public class EnvironmentManagerIntegrationTests {
public void testRefresh() throws Exception {
assertEquals("Hello scope!", properties.getMessage());
// Change the dynamic property source...
this.mvc.perform(post("/application/env").param("message", "Foo")).andExpect(status().isOk()).andExpect(
content().string("{\"message\":\"Foo\"}"));
this.mvc.perform(post("/application/env").param("message", "Foo"))
.andExpect(status().isOk())
.andExpect(content().string("{\"message\":\"Foo\"}"));
assertEquals("Foo", properties.getMessage());
}
@Test
public void testRefreshFails() throws Exception {
try {
this.mvc.perform(post("/application/env").param("delay", "foo")).andExpect(
status().is5xxServerError());
this.mvc.perform(post("/application/env").param("delay", "foo"))
.andExpect(status().is5xxServerError());
fail("expected ServletException");
} catch (ServletException e) {
}
catch (ServletException e) {
// The underlying BindException is not handled by the dispatcher servlet
}
assertEquals(0, properties.getDelay());