closer to jdk-17 changes (#1074)

This commit is contained in:
erabii
2022-09-11 21:01:09 +03:00
committed by GitHub
parent 3704a08be4
commit 2458af5833
3 changed files with 10 additions and 9 deletions

View File

@@ -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;

View File

@@ -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<MapPropertySource> 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<MapPropertySource> 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());

View File

@@ -15,6 +15,5 @@
<suppress files=".*ConfigurationWatcherApplication\.java" checks="HideUtilityClassConstructor"/>
<suppress files=".*DiscoveryServerApplication\.java" checks="HideUtilityClassConstructor"/>
<suppress files=".*KubernetesConfigServerApplication\.java" checks="HideUtilityClassConstructor"/>
<suppress files=".*NormalizedSource\.java" checks="WhitespaceAfter" />
<suppress files=".*Fabric8ConfigContext\.java" checks="WhitespaceAround" />
</suppressions>