Suppress use of configuration properties source in refresh

This commit is contained in:
Dave Syer
2017-10-20 11:18:30 +01:00
parent 1f28206158
commit 2fd2f99c9d
4 changed files with 49 additions and 2 deletions

View File

@@ -39,7 +39,8 @@ public class ContextRefresher {
StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME,
StandardServletEnvironment.JNDI_PROPERTY_SOURCE_NAME,
StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME,
StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME));
StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME,
"configurationProperties"));
private ConfigurableApplicationContext context;
private RefreshScope scope;
@@ -118,6 +119,10 @@ public class ContextRefresher {
capturedPropertySources.remove(source.getName());
}
for (PropertySource<?> source : input.getPropertySources()) {
if ("configurationProperties".equals(source.getName())) {
// Spring Boot artifact, tracking values in the other sources
continue;
}
capturedPropertySources.addLast(source);
}
environment.setActiveProfiles(input.getActiveProfiles());

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2012-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud;
import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import org.springframework.cloud.context.refresh.ContextRefresherTests;
import org.springframework.cloud.endpoint.RefreshEndpointTests;
/**
* A test suite for probing weird ordering problems in the tests.
*
* @author Dave Syer
*/
@RunWith(Suite.class)
@SuiteClasses({ RefreshEndpointTests.class, ContextRefresherTests.class })
@Ignore
public class AdhocTestSuite {
}

View File

@@ -97,8 +97,12 @@ public class RefreshEndpointIntegrationTests {
@RestController
protected static class Controller {
@Value("${message:Hello World!}")
String message;
@Value("${message:Hello World!}")
public void setMessage(String message) {
this.message = message;
}
@RequestMapping("/")
public String hello() {

View File

@@ -28,6 +28,7 @@ import java.util.List;
import java.util.Map;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.boot.Banner.Mode;
import org.springframework.boot.WebApplicationType;
@@ -93,6 +94,7 @@ public class RefreshEndpointTests {
}
@Test
// @Ignore
public void keysComputedWhenChangesInExternalProperties() throws Exception {
this.context = new SpringApplicationBuilder(Empty.class)
.web(WebApplicationType.NONE).bannerMode(Mode.OFF)