Skip to content

Commit 2458af5

Browse files
authored
closer to jdk-17 changes (#1074)
1 parent 3704a08 commit 2458af5

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/NormalizedSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*
2525
* @author wind57
2626
*/
27-
public sealed abstract class NormalizedSource permits NamedSecretNormalizedSource,LabeledSecretNormalizedSource,NamedConfigMapNormalizedSource,LabeledConfigMapNormalizedSource {
27+
public sealed abstract class NormalizedSource permits NamedSecretNormalizedSource, LabeledSecretNormalizedSource, NamedConfigMapNormalizedSource, LabeledConfigMapNormalizedSource {
2828

2929
private final String namespace;
3030

spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/reload/ConfigReloadUtil.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public static <S extends PropertySource<?>> List<S> findPropertySources(Class<S>
8484
else if (sourceClass.isInstance(source)) {
8585
managedSources.add(sourceClass.cast(source));
8686
}
87-
else if (source instanceof BootstrapPropertySource) {
88-
PropertySource<?> propertySource = ((BootstrapPropertySource<?>) source).getDelegate();
87+
else if (source instanceof BootstrapPropertySource<?> bootstrapPropertySource) {
88+
PropertySource<?> propertySource = bootstrapPropertySource.getDelegate();
8989
if (sourceClass.isInstance(propertySource)) {
9090
sources.add(propertySource);
9191
}
@@ -108,14 +108,16 @@ static List<MapPropertySource> locateMapPropertySources(PropertySourceLocator pr
108108

109109
List<MapPropertySource> result = new ArrayList<>();
110110
PropertySource<?> propertySource = propertySourceLocator.locate(environment);
111-
if (propertySource instanceof MapPropertySource) {
112-
result.add((MapPropertySource) propertySource);
111+
if (propertySource instanceof MapPropertySource mapPropertySource) {
112+
result.add(mapPropertySource);
113113
}
114114
else if (propertySource instanceof CompositePropertySource source) {
115115

116-
List<MapPropertySource> list = source.getPropertySources().stream()
117-
.filter(p -> p instanceof MapPropertySource).map(x -> (MapPropertySource) x).toList();
118-
result.addAll(list);
116+
source.getPropertySources().forEach(x -> {
117+
if (x instanceof MapPropertySource mapPropertySource) {
118+
result.add(mapPropertySource);
119+
}
120+
});
119121
}
120122
else {
121123
LOG.debug(() -> "Found property source that cannot be handled: " + propertySource.getClass());

src/checkstyle/checkstyle-suppressions.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@
1515
<suppress files=".*ConfigurationWatcherApplication\.java" checks="HideUtilityClassConstructor"/>
1616
<suppress files=".*DiscoveryServerApplication\.java" checks="HideUtilityClassConstructor"/>
1717
<suppress files=".*KubernetesConfigServerApplication\.java" checks="HideUtilityClassConstructor"/>
18-
<suppress files=".*NormalizedSource\.java" checks="WhitespaceAfter" />
1918
<suppress files=".*Fabric8ConfigContext\.java" checks="WhitespaceAround" />
2019
</suppressions>

0 commit comments

Comments
 (0)