diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/NormalizedSource.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/NormalizedSource.java index 43c3d0fe..b0500c75 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/NormalizedSource.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/NormalizedSource.java @@ -24,7 +24,7 @@ import java.util.Optional; * * @author wind57 */ -public sealed abstract class NormalizedSource permits NamedSecretNormalizedSource,LabeledSecretNormalizedSource,NamedConfigMapNormalizedSource,LabeledConfigMapNormalizedSource { +public sealed abstract class NormalizedSource permits NamedSecretNormalizedSource, LabeledSecretNormalizedSource, NamedConfigMapNormalizedSource, LabeledConfigMapNormalizedSource { private final String namespace; diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/reload/ConfigReloadUtil.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/reload/ConfigReloadUtil.java index 90b77eba..fe77e472 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/reload/ConfigReloadUtil.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/reload/ConfigReloadUtil.java @@ -84,8 +84,8 @@ public final class ConfigReloadUtil { else if (sourceClass.isInstance(source)) { managedSources.add(sourceClass.cast(source)); } - else if (source instanceof BootstrapPropertySource) { - PropertySource propertySource = ((BootstrapPropertySource) source).getDelegate(); + else if (source instanceof BootstrapPropertySource bootstrapPropertySource) { + PropertySource propertySource = bootstrapPropertySource.getDelegate(); if (sourceClass.isInstance(propertySource)) { sources.add(propertySource); } @@ -108,14 +108,16 @@ public final class ConfigReloadUtil { List result = new ArrayList<>(); PropertySource propertySource = propertySourceLocator.locate(environment); - if (propertySource instanceof MapPropertySource) { - result.add((MapPropertySource) propertySource); + if (propertySource instanceof MapPropertySource mapPropertySource) { + result.add(mapPropertySource); } else if (propertySource instanceof CompositePropertySource source) { - List list = source.getPropertySources().stream() - .filter(p -> p instanceof MapPropertySource).map(x -> (MapPropertySource) x).toList(); - result.addAll(list); + source.getPropertySources().forEach(x -> { + if (x instanceof MapPropertySource mapPropertySource) { + result.add(mapPropertySource); + } + }); } else { LOG.debug(() -> "Found property source that cannot be handled: " + propertySource.getClass()); diff --git a/src/checkstyle/checkstyle-suppressions.xml b/src/checkstyle/checkstyle-suppressions.xml index 9dd33353..deeaaf2f 100644 --- a/src/checkstyle/checkstyle-suppressions.xml +++ b/src/checkstyle/checkstyle-suppressions.xml @@ -15,6 +15,5 @@ -