diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundrySecurityService.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundrySecurityService.java index 4add4c0943..d75725e68d 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundrySecurityService.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundrySecurityService.java @@ -53,8 +53,6 @@ class ReactiveCloudFoundrySecurityService { private final String cloudControllerUrl; - private Mono uaaUrl; - ReactiveCloudFoundrySecurityService(WebClient.Builder webClientBuilder, String cloudControllerUrl, boolean skipSslValidation) { Assert.notNull(webClientBuilder, "WebClient must not be null"); @@ -149,7 +147,7 @@ class ReactiveCloudFoundrySecurityService { * @return the UAA url Mono */ Mono getUaaUrl() { - this.uaaUrl = this.webClient.get() + return this.webClient.get() .uri(this.cloudControllerUrl + "/info") .retrieve() .bodyToMono(Map.class) @@ -157,7 +155,6 @@ class ReactiveCloudFoundrySecurityService { .cache() .onErrorMap((ex) -> new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE, "Unable to fetch token keys from UAA.")); - return this.uaaUrl; } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityInterceptor.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityInterceptor.java index 01eafcf651..c5c4b2c8e4 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityInterceptor.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,7 +86,7 @@ class CloudFoundrySecurityInterceptor { return SecurityResponse.success(); } - private void check(HttpServletRequest request, EndpointId endpointId) throws Exception { + private void check(HttpServletRequest request, EndpointId endpointId) { Token token = getToken(request); this.tokenValidator.validate(token); AccessLevel accessLevel = this.cloudFoundrySecurityService.getAccessLevel(token.toString(), this.applicationId); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/OnAvailableEndpointCondition.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/OnAvailableEndpointCondition.java index 4478b0ed94..a485aa2a4a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/OnAvailableEndpointCondition.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/OnAvailableEndpointCondition.java @@ -143,11 +143,8 @@ class OnAvailableEndpointCondition extends SpringBootCondition { } private Boolean isEnabledByDefault(Environment environment) { - Optional enabledByDefault = enabledByDefaultCache.get(environment); - if (enabledByDefault == null) { - enabledByDefault = Optional.ofNullable(environment.getProperty(ENABLED_BY_DEFAULT_KEY, Boolean.class)); - enabledByDefaultCache.put(environment, enabledByDefault); - } + Optional enabledByDefault = enabledByDefaultCache.computeIfAbsent(environment, + (ignore) -> Optional.ofNullable(environment.getProperty(ENABLED_BY_DEFAULT_KEY, Boolean.class))); return enabledByDefault.orElse(null); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/expose/IncludeExcludeEndpointFilter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/expose/IncludeExcludeEndpointFilter.java index d2c738b5e2..00affa4cff 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/expose/IncludeExcludeEndpointFilter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/expose/IncludeExcludeEndpointFilter.java @@ -150,7 +150,7 @@ public class IncludeExcludeEndpointFilter> implem private final Set endpointIds; EndpointPatterns(String[] patterns) { - this((patterns != null) ? Arrays.asList(patterns) : (Collection) null); + this((patterns != null) ? Arrays.asList(patterns) : null); } EndpointPatterns(Collection patterns) { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/ManagementContextFactory.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/ManagementContextFactory.java index 0871218563..4b98cdfc51 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/ManagementContextFactory.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/ManagementContextFactory.java @@ -60,8 +60,8 @@ public final class ManagementContextFactory { Environment parentEnvironment = parentContext.getEnvironment(); ConfigurableEnvironment childEnvironment = ApplicationContextFactory.DEFAULT .createEnvironment(this.webApplicationType); - if (parentEnvironment instanceof ConfigurableEnvironment) { - childEnvironment.setConversionService(((ConfigurableEnvironment) parentEnvironment).getConversionService()); + if (parentEnvironment instanceof ConfigurableEnvironment configurableEnvironment) { + childEnvironment.setConversionService((configurableEnvironment).getConversionService()); } ConfigurableApplicationContext managementContext = ApplicationContextFactory.DEFAULT .create(this.webApplicationType); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ChildManagementContextInitializer.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ChildManagementContextInitializer.java index a4d423dfce..38a6a68f36 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ChildManagementContextInitializer.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ChildManagementContextInitializer.java @@ -217,8 +217,8 @@ class ChildManagementContextInitializer } static void addIfPossible(ApplicationContext parentContext, ConfigurableApplicationContext childContext) { - if (parentContext instanceof ConfigurableApplicationContext) { - add((ConfigurableApplicationContext) parentContext, childContext); + if (parentContext instanceof ConfigurableApplicationContext configurableApplicationContext) { + add(configurableApplicationContext, childContext); } } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicator.java index b92c7398a6..caef14b9bc 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicator.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -101,7 +101,7 @@ public class DataSourceHealthIndicator extends AbstractHealthIndicator implement } } - private void doDataSourceHealthCheck(Health.Builder builder) throws Exception { + private void doDataSourceHealthCheck(Health.Builder builder) { builder.up().withDetail("database", getProduct()); String validationQuery = this.query; if (StringUtils.hasText(validationQuery)) { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/context/ShutdownEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/context/ShutdownEndpointTests.java index 45b37c3e6f..018dd3a905 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/context/ShutdownEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/context/ShutdownEndpointTests.java @@ -60,7 +60,7 @@ class ShutdownEndpointTests { Thread.currentThread().setContextClassLoader(previousTccl); } assertThat(result.getMessage()).startsWith("Shutting down"); - assertThat(((ConfigurableApplicationContext) context).isActive()).isTrue(); + assertThat(context.isActive()).isTrue(); assertThat(config.latch.await(10, TimeUnit.SECONDS)).isTrue(); assertThat(config.threadContextClassLoader).isEqualTo(getClass().getClassLoader()); }); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java index 3c050a0856..0474d2d0af 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java @@ -99,7 +99,7 @@ public class BatchAutoConfiguration { @ConditionalOnMissingBean(JobOperator.class) public SimpleJobOperator jobOperator(ObjectProvider jobParametersConverter, JobExplorer jobExplorer, JobLauncher jobLauncher, ListableJobLocator jobRegistry, - JobRepository jobRepository) throws Exception { + JobRepository jobRepository) { SimpleJobOperator factory = new SimpleJobOperator(); factory.setJobExplorer(jobExplorer); factory.setJobLauncher(jobLauncher); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseDataConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseDataConfiguration.java index 20826c607b..1b408f8766 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseDataConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseDataConfiguration.java @@ -61,7 +61,7 @@ class CouchbaseDataConfiguration { @ConditionalOnMissingBean(name = BeanNames.COUCHBASE_MAPPING_CONTEXT) CouchbaseMappingContext couchbaseMappingContext(CouchbaseDataProperties properties, ApplicationContext applicationContext, CouchbaseCustomConversions couchbaseCustomConversions) - throws Exception { + throws ClassNotFoundException { CouchbaseMappingContext mappingContext = new CouchbaseMappingContext(); mappingContext.setInitialEntitySet(new EntityScanner(applicationContext).scan(Document.class)); mappingContext.setSimpleTypeHolder(couchbaseCustomConversions.getSimpleTypeHolder()); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/logging/ConditionEvaluationReportLogger.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/logging/ConditionEvaluationReportLogger.java index 49a3036fd6..1af820991a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/logging/ConditionEvaluationReportLogger.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/logging/ConditionEvaluationReportLogger.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,7 +80,7 @@ class ConditionEvaluationReportLogger { private void logMessage(String logLevel) { this.logger.info(String.format("%n%nError starting ApplicationContext. To display the " - + "condition evaluation report re-run your application with '" + logLevel + "' enabled.")); + + "condition evaluation report re-run your application with '%s' enabled.", logLevel)); } } diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploader.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploader.java index 8cfe3144db..44bf7d24d5 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploader.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploader.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -92,15 +92,14 @@ public class ClassPathChangeUploader implements ApplicationListener> initializers) { + void configure(MergedContextConfiguration mergedConfig, List> initializers) { WebMergedContextConfiguration webMergedConfig = (WebMergedContextConfiguration) mergedConfig; addMockServletContext(initializers, webMergedConfig); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/SimpleConfigurationMetadataRepository.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/SimpleConfigurationMetadataRepository.java index bba6c25627..bdfc91cb20 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/SimpleConfigurationMetadataRepository.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/SimpleConfigurationMetadataRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolver.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolver.java index e71fb074eb..c4808a93a7 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolver.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolver.java @@ -204,7 +204,7 @@ class PropertyDescriptorResolver { MetadataGenerationEnvironment env) { if (constructors.size() == 1) { ExecutableElement candidate = constructors.get(0); - if (candidate.getParameters().size() > 0 && !env.hasAutowiredAnnotation(candidate)) { + if (!candidate.getParameters().isEmpty() && !env.hasAutowiredAnnotation(candidate)) { if (type.getNestingKind() == NestingKind.MEMBER && candidate.getModifiers().contains(Modifier.PRIVATE)) { return null; diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/NativeImagePluginAction.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/NativeImagePluginAction.java index 3cc2bf7b2b..061d073e61 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/NativeImagePluginAction.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/NativeImagePluginAction.java @@ -47,8 +47,7 @@ import org.springframework.boot.gradle.tasks.bundling.BootJar; class NativeImagePluginAction implements PluginApplicationAction { @Override - public Class> getPluginClass() - throws ClassNotFoundException, NoClassDefFoundError { + public Class> getPluginClass() { return NativeImagePlugin.class; } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/main/java/org/springframework/boot/jarmode/layertools/HelpCommand.java b/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/main/java/org/springframework/boot/jarmode/layertools/HelpCommand.java index 70f5d385c3..4f25c80dc2 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/main/java/org/springframework/boot/jarmode/layertools/HelpCommand.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/main/java/org/springframework/boot/jarmode/layertools/HelpCommand.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,10 +40,10 @@ class HelpCommand extends Command { @Override protected void run(Map options, List parameters) { - run(System.out, options, parameters); + run(System.out, parameters); } - void run(PrintStream out, Map options, List parameters) { + void run(PrintStream out, List parameters) { Command command = (!parameters.isEmpty()) ? Command.find(this.commands, parameters.get(0)) : null; if (command != null) { printCommandHelp(out, command); @@ -66,8 +66,7 @@ class HelpCommand extends Command { } private void printOptionSummary(PrintStream out, Option option, int padding) { - out.println(String.format(" --%-" + padding + "s %s", option.getNameAndValueDescription(), - option.getDescription())); + out.printf(" --%-" + padding + "s %s%n", option.getNameAndValueDescription(), option.getDescription()); } private String getUsage(Command command) { @@ -76,7 +75,7 @@ class HelpCommand extends Command { if (!command.getOptions().isEmpty()) { usage.append(" [options]"); } - command.getParameters().getDescriptions().forEach((param) -> usage.append(" " + param)); + command.getParameters().getDescriptions().forEach((param) -> usage.append(" ").append(param)); return usage.toString(); } @@ -95,7 +94,7 @@ class HelpCommand extends Command { } private void printCommandSummary(PrintStream out, Command command, int padding) { - out.println(String.format(" %-" + padding + "s %s", command.getName(), command.getDescription())); + out.printf(" %-" + padding + "s %s%n", command.getName(), command.getDescription()); } private String getJavaCommand() { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/java/org/springframework/boot/jarmode/layertools/HelpCommandTests.java b/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/java/org/springframework/boot/jarmode/layertools/HelpCommandTests.java index 4491d8798f..9acb9c9c6c 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/java/org/springframework/boot/jarmode/layertools/HelpCommandTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/java/org/springframework/boot/jarmode/layertools/HelpCommandTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,13 +62,13 @@ class HelpCommandTests { @Test void runWhenHasNoParametersPrintsUsage() { - this.command.run(this.out, Collections.emptyMap(), Collections.emptyList()); + this.command.run(this.out, Collections.emptyList()); assertThat(this.out).hasSameContentAsResource("help-output.txt"); } @Test void runWhenHasNoCommandParameterPrintsUsage() { - this.command.run(this.out, Collections.emptyMap(), Arrays.asList("extract")); + this.command.run(this.out, Arrays.asList("extract")); System.out.println(this.out); assertThat(this.out).hasSameContentAsResource("help-extract-output.txt"); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CustomLayersProvider.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CustomLayersProvider.java index e78d817e34..5f3d6e6c87 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CustomLayersProvider.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CustomLayersProvider.java @@ -123,7 +123,7 @@ class CustomLayersProvider { return new IncludeExcludeContentSelector<>(layer, includes, excludes, filterFactory); } - private ContentSelector getLibrarySelector(Element element, + private ContentSelector getLibrarySelector(Element element, Function> filterFactory) { Layer layer = new Layer(element.getAttribute("layer")); List includes = getChildNodeTextContent(element, "include"); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataLoaders.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataLoaders.java index 2857c53464..2276d440b3 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataLoaders.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataLoaders.java @@ -100,15 +100,14 @@ class ConfigDataLoaders { private ConfigDataLoader getLoader(ConfigDataLoaderContext context, R resource) { ConfigDataLoader result = null; for (int i = 0; i < this.loaders.size(); i++) { - ConfigDataLoader candidate = this.loaders.get(i); + ConfigDataLoader candidate = this.loaders.get(i); if (this.resourceTypes.get(i).isInstance(resource)) { - ConfigDataLoader loader = (ConfigDataLoader) candidate; - if (loader.isLoadable(context, resource)) { + if (candidate.isLoadable(context, resource)) { if (result != null) { throw new IllegalStateException("Multiple loaders found for resource '" + resource + "' [" + candidate.getClass().getName() + "," + result.getClass().getName() + "]"); } - result = loader; + result = candidate; } } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/NotConstructorBoundInjectionFailureAnalyzer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/NotConstructorBoundInjectionFailureAnalyzer.java index 2e4fc05a48..228aa5ed48 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/NotConstructorBoundInjectionFailureAnalyzer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/NotConstructorBoundInjectionFailureAnalyzer.java @@ -49,9 +49,9 @@ class NotConstructorBoundInjectionFailureAnalyzer InjectionPoint injectionPoint = findInjectionPoint(rootFailure); if (isConstructorBindingConfigurationProperties(injectionPoint)) { String simpleName = injectionPoint.getMember().getDeclaringClass().getSimpleName(); - String action = String.format("Update your configuration so that " + simpleName + " is defined via @" + String action = "Update your configuration so that " + simpleName + " is defined via @" + ConfigurationPropertiesScan.class.getSimpleName() + " or @" - + EnableConfigurationProperties.class.getSimpleName() + ".", simpleName); + + EnableConfigurationProperties.class.getSimpleName() + "."; return new FailureAnalysis( simpleName + " is annotated with @" + ConstructorBinding.class.getSimpleName() + " but it is defined as a regular bean which caused dependency injection to fail.", diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DefaultBindConstructorProvider.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DefaultBindConstructorProvider.java index 54b454ebca..609b8ebccc 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DefaultBindConstructorProvider.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DefaultBindConstructorProvider.java @@ -135,7 +135,7 @@ class DefaultBindConstructorProvider implements BindConstructorProvider { return new Constructor[0]; } return Arrays.stream(type.getDeclaredConstructors()) - .filter((constructor) -> isNonSynthetic(constructor, type)) + .filter(Constructors::isNonSynthetic) .toArray(Constructor[]::new); } @@ -148,7 +148,7 @@ class DefaultBindConstructorProvider implements BindConstructorProvider { } } - private static boolean isNonSynthetic(Constructor constructor, Class type) { + private static boolean isNonSynthetic(Constructor constructor) { return !constructor.isSynthetic(); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanDefinitionOverrideFailureAnalyzer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanDefinitionOverrideFailureAnalyzer.java index ca536fcc9a..439f9d23a5 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanDefinitionOverrideFailureAnalyzer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanDefinitionOverrideFailureAnalyzer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,11 +46,11 @@ class BeanDefinitionOverrideFailureAnalyzer extends AbstractFailureAnalyzer Set sortedStrings(Collection input) { + private Set sortedStrings(Collection input) { return sortedStrings(input, Function.identity()); }