Ensure app index is used when profiles actrive
This commit is contained in:
@@ -91,15 +91,15 @@ public class ContextIdApplicationContextInitializer implements
|
||||
private String getApplicationId(ConfigurableEnvironment environment) {
|
||||
String name = environment.resolvePlaceholders(this.name);
|
||||
String index = environment.resolvePlaceholders(INDEX_PATTERN);
|
||||
if (!"null".equals(index)) {
|
||||
return name + ":" + index;
|
||||
}
|
||||
|
||||
String profiles = StringUtils.arrayToCommaDelimitedString(environment
|
||||
.getActiveProfiles());
|
||||
if (StringUtils.hasText(profiles)) {
|
||||
name = name + ":" + profiles;
|
||||
}
|
||||
if (!"null".equals(index)) {
|
||||
name = name + ":" + index;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,9 +51,9 @@ public class ContextIdApplicationContextInitializerTests {
|
||||
public void testNameAndProfiles() {
|
||||
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
TestUtils.addEnviroment(context, "spring.application.name:foo",
|
||||
"spring.profiles.active: spam,bar");
|
||||
"spring.profiles.active: spam,bar", "spring.application.index:12");
|
||||
this.initializer.initialize(context);
|
||||
assertEquals("foo:spam,bar", context.getId());
|
||||
assertEquals("foo:spam,bar:12", context.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user