Ensure config server works with Spring Boot 2.4
Since 2.4 the names of property sources have changed, so we have to change the `clean()` method in `NativeEnvironmentRepository` in order not to simply omit all the sources.
This commit is contained in:
@@ -231,6 +231,7 @@ public class NativeEnvironmentRepository implements EnvironmentRepository, Searc
|
||||
}
|
||||
// TODO: needed anymore?
|
||||
name = name.replace("applicationConfig: [", "");
|
||||
name = name.replace("file [", "");
|
||||
name = name.replace("]", "");
|
||||
if (this.searchLocations != null) {
|
||||
boolean matches = false;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.config.server.environment;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -25,6 +26,7 @@ import org.junit.Test;
|
||||
import org.springframework.boot.WebApplicationType;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.environment.PropertySource;
|
||||
import org.springframework.cloud.config.server.environment.SearchPathLocator.Locations;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
@@ -90,6 +92,16 @@ public class NativeEnvironmentRepositoryTests {
|
||||
assertThat(environment.getVersion()).as("version was wrong").isEqualTo("myversion");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cleanBoot24() {
|
||||
Environment environment = new Environment("application");
|
||||
environment.add(new PropertySource(
|
||||
"Config resource 'file [/tmp/config-repo-7780026223759117699/application-dev.yml]' via location 'file:/tmp/config-repo-7780026223759117699/'",
|
||||
Collections.singletonMap("foo", "bar")));
|
||||
assertThat(environment.getPropertySources().size()).isEqualTo(1);
|
||||
assertThat(environment.getPropertySources().get(0).getName().contains("application-dev.yml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: configdata
|
||||
public void labelled() {
|
||||
|
||||
Reference in New Issue
Block a user