Bumping versions
This commit is contained in:
@@ -30,6 +30,7 @@ public final class IdUtils {
|
||||
public static final String DEFAULT_SERVICE_ID_STRING = "${vcap.application.name:${spring.application.name:application}}:${vcap.application.instance_index:${spring.application.index:${local.server.port:${server.port:0}}}}:${vcap.application.instance_id:${cachedrandom.${vcap.application.name:${spring.application.name:application}}.value}}";
|
||||
|
||||
public static final String DEFAULT_SERVICE_ID_WITH_ACTIVE_PROFILES_STRING = "${vcap.application.name:${spring.application.name:application}:${spring.profiles.active}}:${vcap.application.instance_index:${spring.application.index:${local.server.port:${server.port:0}}}}:${vcap.application.instance_id:${cachedrandom.${vcap.application.name:${spring.application.name:application}}.value}}";
|
||||
|
||||
// @checkstyle:on
|
||||
|
||||
private IdUtils() {
|
||||
@@ -66,11 +67,13 @@ public final class IdUtils {
|
||||
*/
|
||||
public static String getResolvedServiceId(PropertyResolver resolver) {
|
||||
final String unresolvedServiceId;
|
||||
// addition of active profiles at the 2nd position of the service ID breaks backwards-compatibility,
|
||||
// addition of active profiles at the 2nd position of the service ID breaks
|
||||
// backwards-compatibility,
|
||||
// so we fall back to the old implementation in case no profiles are active
|
||||
if (StringUtils.hasText(resolver.getProperty("spring.profiles.active"))) {
|
||||
unresolvedServiceId = getUnresolvedServiceIdWithActiveProfiles();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
unresolvedServiceId = getUnresolvedServiceId();
|
||||
}
|
||||
return resolver.resolvePlaceholders(unresolvedServiceId);
|
||||
@@ -78,7 +81,6 @@ public final class IdUtils {
|
||||
|
||||
/**
|
||||
* Gets the unresolved template for the service id <i>without active profiles.</i>
|
||||
*
|
||||
* @return The combination of properties to create a unique service id.
|
||||
*/
|
||||
public static String getUnresolvedServiceId() {
|
||||
@@ -87,7 +89,6 @@ public final class IdUtils {
|
||||
|
||||
/**
|
||||
* Gets the unresolved template for the service id including active profiles.
|
||||
*
|
||||
* @return The combination of properties to create a unique service id.
|
||||
*/
|
||||
public static String getUnresolvedServiceIdWithActiveProfiles() {
|
||||
|
||||
@@ -116,7 +116,8 @@ public class IdUtilsTests {
|
||||
|
||||
@Test
|
||||
public void testUnresolvedServiceIdWithActiveProfiles() {
|
||||
then(IdUtils.DEFAULT_SERVICE_ID_WITH_ACTIVE_PROFILES_STRING).isEqualTo(IdUtils.getUnresolvedServiceIdWithActiveProfiles());
|
||||
then(IdUtils.DEFAULT_SERVICE_ID_WITH_ACTIVE_PROFILES_STRING)
|
||||
.isEqualTo(IdUtils.getUnresolvedServiceIdWithActiveProfiles());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -148,7 +149,8 @@ public class IdUtilsTests {
|
||||
env.setProperty("cachedrandom.springname.value", "123abc");
|
||||
then("springname:1234:123abc").isEqualTo(IdUtils.getResolvedServiceId(env));
|
||||
|
||||
// ensure that for spring.profiles.active, empty string value is equivalent to not being set at all
|
||||
// ensure that for spring.profiles.active, empty string value is equivalent to not
|
||||
// being set at all
|
||||
env.setProperty("spring.profiles.active", "");
|
||||
then("springname:1234:123abc").isEqualTo(IdUtils.getResolvedServiceId(env));
|
||||
}
|
||||
@@ -179,4 +181,5 @@ public class IdUtilsTests {
|
||||
env.setProperty("spring.profiles.active", "123profile");
|
||||
then("springname:123profile:1234:123abc").isEqualTo(IdUtils.getResolvedServiceId(env));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user