Bumping versions

This commit is contained in:
buildmaster
2020-09-30 11:48:26 +00:00
parent 634c382089
commit 6674497d93
4 changed files with 26 additions and 47 deletions

View File

@@ -73,9 +73,8 @@ public class ConfigMapConfigProperties extends AbstractConfigProperties {
*/
public List<NormalizedSource> determineSources() {
if (this.sources.isEmpty()) {
return Collections.singletonList(
new NormalizedSource(ConfigMapConfigProperties.this.name,
ConfigMapConfigProperties.this.namespace));
return Collections.singletonList(new NormalizedSource(ConfigMapConfigProperties.this.name,
ConfigMapConfigProperties.this.namespace));
}
return this.sources.stream().map(s -> s.normalize(this.name, this.namespace)).collect(Collectors.toList());

View File

@@ -39,26 +39,21 @@ public final class ConfigUtils {
throw new IllegalStateException("Can't instantiate a utility class");
}
public static String getApplicationName(Environment env, String configName,
String configurationTarget) {
public static String getApplicationName(Environment env, String configName, String configurationTarget) {
if (StringUtils.isEmpty(configName)) {
// TODO: use relaxed binding
LOG.debug(configurationTarget
+ " name has not been set, taking it from property/env "
+ SPRING_APPLICATION_NAME + " (default=" + FALLBACK_APPLICATION_NAME
+ ")");
configName = env.getProperty(SPRING_APPLICATION_NAME,
FALLBACK_APPLICATION_NAME);
LOG.debug(configurationTarget + " name has not been set, taking it from property/env "
+ SPRING_APPLICATION_NAME + " (default=" + FALLBACK_APPLICATION_NAME + ")");
configName = env.getProperty(SPRING_APPLICATION_NAME, FALLBACK_APPLICATION_NAME);
}
return configName;
}
public static String getApplicationNamespace(KubernetesClient client,
String configNamespace, String configurationTarget) {
public static String getApplicationNamespace(KubernetesClient client, String configNamespace,
String configurationTarget) {
if (StringUtils.isEmpty(configNamespace)) {
LOG.debug(configurationTarget
+ " namespace has not been set, taking it from client (ns="
LOG.debug(configurationTarget + " namespace has not been set, taking it from client (ns="
+ client.getNamespace() + ")");
configNamespace = client.getNamespace();
}

View File

@@ -93,13 +93,11 @@ public abstract class ConfigurationChangeDetector {
return !Objects.equals(leftMap, rightMap);
}
protected boolean changed(List<? extends MapPropertySource> left,
List<? extends MapPropertySource> right) {
protected boolean changed(List<? extends MapPropertySource> left, List<? extends MapPropertySource> right) {
if (left.size() != right.size()) {
this.log.warn(
"The current number of ConfigMap PropertySources does not match "
+ "the ones loaded from the Kubernetes - No reload will take place");
this.log.warn("The current number of ConfigMap PropertySources does not match "
+ "the ones loaded from the Kubernetes - No reload will take place");
return false;
}
@@ -148,8 +146,7 @@ public abstract class ConfigurationChangeDetector {
managedSources.add(sourceClass.cast(source));
}
else if (source instanceof BootstrapPropertySource) {
PropertySource<?> propertySource = ((BootstrapPropertySource<?>) source)
.getDelegate();
PropertySource<?> propertySource = ((BootstrapPropertySource<?>) source).getDelegate();
if (sourceClass.isInstance(propertySource)) {
sources.add(propertySource);
}
@@ -184,10 +181,8 @@ public abstract class ConfigurationChangeDetector {
result.add((MapPropertySource) propertySource);
}
else if (propertySource instanceof CompositePropertySource) {
result.addAll(((CompositePropertySource) propertySource).getPropertySources()
.stream()
.filter(p -> p instanceof MapPropertySource)
.map(p -> (MapPropertySource) p)
result.addAll(((CompositePropertySource) propertySource).getPropertySources().stream()
.filter(p -> p instanceof MapPropertySource).map(p -> (MapPropertySource) p)
.collect(Collectors.toList()));
}
else {

View File

@@ -33,8 +33,7 @@ import org.springframework.core.env.MapPropertySource;
*/
public class ConfigurationChangeDetectorTest {
private final ConfigurationChangeDetectorStub stub = new ConfigurationChangeDetectorStub(
null, null, null, null);
private final ConfigurationChangeDetectorStub stub = new ConfigurationChangeDetectorStub(null, null, null, null);
@Test
public void testChangedTwoNulls() {
@@ -44,16 +43,14 @@ public class ConfigurationChangeDetectorTest {
@Test
public void testChangedLeftNullRightNonNull() {
MapPropertySource right = new MapPropertySource("rightNonNull",
Collections.emptyMap());
MapPropertySource right = new MapPropertySource("rightNonNull", Collections.emptyMap());
boolean changed = stub.changed(null, right);
Assert.assertTrue(changed);
}
@Test
public void testChangedLeftNonNullRightNull() {
MapPropertySource left = new MapPropertySource("leftNonNull",
Collections.emptyMap());
MapPropertySource left = new MapPropertySource("leftNonNull", Collections.emptyMap());
boolean changed = stub.changed(left, null);
Assert.assertTrue(changed);
}
@@ -87,8 +84,7 @@ public class ConfigurationChangeDetectorTest {
@Test
public void testChangedListsDifferentSizes() {
List<MapPropertySource> left = Collections
.singletonList(new MapPropertySource("one", Collections.emptyMap()));
List<MapPropertySource> left = Collections.singletonList(new MapPropertySource("one", Collections.emptyMap()));
List<MapPropertySource> right = Collections.emptyList();
boolean changed = stub.changed(left, right);
Assert.assertFalse(changed);
@@ -101,10 +97,8 @@ public class ConfigurationChangeDetectorTest {
leftMap.put("key", value);
Map<String, Object> rightMap = new HashMap<>();
leftMap.put("anotherKey", value);
List<MapPropertySource> left = Collections
.singletonList(new MapPropertySource("one", leftMap));
List<MapPropertySource> right = Collections
.singletonList(new MapPropertySource("two", rightMap));
List<MapPropertySource> left = Collections.singletonList(new MapPropertySource("one", leftMap));
List<MapPropertySource> right = Collections.singletonList(new MapPropertySource("two", rightMap));
boolean changed = stub.changed(left, right);
Assert.assertTrue(changed);
}
@@ -116,10 +110,8 @@ public class ConfigurationChangeDetectorTest {
leftMap.put("key", value);
Map<String, Object> rightMap = new HashMap<>();
leftMap.put("key", value);
List<MapPropertySource> left = Collections
.singletonList(new MapPropertySource("one", leftMap));
List<MapPropertySource> right = Collections
.singletonList(new MapPropertySource("two", rightMap));
List<MapPropertySource> left = Collections.singletonList(new MapPropertySource("one", leftMap));
List<MapPropertySource> right = Collections.singletonList(new MapPropertySource("two", rightMap));
boolean changed = stub.changed(left, right);
Assert.assertTrue(changed);
}
@@ -127,12 +119,10 @@ public class ConfigurationChangeDetectorTest {
/**
* only needed to test some protected methods it defines
*/
private static final class ConfigurationChangeDetectorStub
extends ConfigurationChangeDetector {
private static final class ConfigurationChangeDetectorStub extends ConfigurationChangeDetector {
private ConfigurationChangeDetectorStub(ConfigurableEnvironment environment,
ConfigReloadProperties properties, KubernetesClient kubernetesClient,
ConfigurationUpdateStrategy strategy) {
private ConfigurationChangeDetectorStub(ConfigurableEnvironment environment, ConfigReloadProperties properties,
KubernetesClient kubernetesClient, ConfigurationUpdateStrategy strategy) {
super(environment, properties, kubernetesClient, strategy);
}