diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 854b5bf05230..dc22d96d2104 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -118,4 +118,4 @@ - \ No newline at end of file + diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cassandra/CassandraHealthContributorConfigurations.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cassandra/CassandraHealthContributorConfigurations.java index 570d5d08f1f3..a1c34b923909 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cassandra/CassandraHealthContributorConfigurations.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cassandra/CassandraHealthContributorConfigurations.java @@ -38,6 +38,8 @@ */ class CassandraHealthContributorConfigurations { + + @Configuration(proxyBeanMethods = false) @ConditionalOnBean(CqlSession.class) static class CassandraDriverConfiguration diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscoverer.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscoverer.java index 173bcbe9e951..7c1941bd801a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscoverer.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscoverer.java @@ -65,11 +65,7 @@ public CloudFoundryWebEndpointDiscoverer(ApplicationContext applicationContext, @Override protected boolean isExtensionTypeExposed(Class extensionBeanType) { - if (isHealthEndpointExtension(extensionBeanType) && !isCloudFoundryHealthEndpointExtension(extensionBeanType)) { - // Filter regular health endpoint extensions so a CF version can replace them - return false; - } - return true; + return !(isHealthEndpointExtension(extensionBeanType) && !isCloudFoundryHealthEndpointExtension(extensionBeanType)); } private boolean isHealthEndpointExtension(Class extensionBeanType) { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java index 35ba2cab29e9..7a2077ba5c00 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java @@ -125,7 +125,7 @@ public CloudFoundryWebEndpointServletHandlerMapping cloudFoundryWebEndpointServl allEndpoints.addAll(webEndpoints); allEndpoints.addAll(servletEndpointsSupplier.getEndpoints()); allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints()); - return new CloudFoundryWebEndpointServletHandlerMapping(new EndpointMapping("/cloudfoundryapplication"), + return new CloudFoundryWebEndpointServletHandlerMapping(new EndpointMapping(BASE_PATH), webEndpoints, endpointMediaTypes, getCorsConfiguration(), securityInterceptor, allEndpoints); } 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 a485aa2a4a10..1cbdff164110 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 @@ -86,7 +86,7 @@ private Class getTarget(ConditionContext context, AnnotatedTypeMetadata metad try { return ClassUtils.forName(methodMetadata.getReturnTypeName(), context.getClassLoader()); } - catch (Throwable ex) { + catch (Exception ex) { throw new IllegalStateException("Failed to extract endpoint id for " + methodMetadata.getDeclaringClassName() + "." + methodMetadata.getMethodName(), ex); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/Log4J2MetricsAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/Log4J2MetricsAutoConfiguration.java index 9da1b3aef576..4e69216a3b4c 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/Log4J2MetricsAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/Log4J2MetricsAutoConfiguration.java @@ -63,7 +63,7 @@ public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeM .match("LoggerContext was an instance of org.apache.logging.log4j.core.LoggerContext"); } } - catch (Throwable ex) { + catch (Exception ex) { // Continue with no match } return ConditionOutcome diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsProperties.java index 2bafe29923f2..2be30095fe13 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsProperties.java @@ -81,6 +81,9 @@ public Map getEnable() { @Deprecated(since = "3.2.0", forRemoval = true) @DeprecatedConfigurationProperty(replacement = "management.observations.key-values", since = "3.2.0") + /** + * @deprecated since 3.2.0 + */ public Map getTags() { return this.tags; } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/otlp/OtlpProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/otlp/OtlpProperties.java index e9a038d3e664..bc5acf2bb915 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/otlp/OtlpProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/otlp/OtlpProperties.java @@ -80,11 +80,17 @@ public void setAggregationTemporality(AggregationTemporality aggregationTemporal @Deprecated(since = "3.2.0", forRemoval = true) @DeprecatedConfigurationProperty(replacement = "management.opentelemetry.resource-attributes", since = "3.2.0") + /** + * @deprecated since 3.2.0 + */ public Map getResourceAttributes() { return this.resourceAttributes; } @Deprecated(since = "3.2.0", forRemoval = true) + /** + * @deprecated since 3.2.0 + */ public void setResourceAttributes(Map resourceAttributes) { this.resourceAttributes = resourceAttributes; } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfiguration.java index 3fde9bb60b7e..acda3bcd8a51 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfiguration.java @@ -87,6 +87,7 @@ public class BraveAutoConfiguration { * Default value for application name if {@code spring.application.name} is not set. */ private static final String DEFAULT_APPLICATION_NAME = "application"; + private static final String SPAN_JOINING = "management.tracing.brave.span-joining-supported"; @Bean @ConditionalOnMissingBean @@ -106,17 +107,17 @@ public Tracing braveTracing(Environment environment, TracingProperties propertie if (properties.getPropagation().getType() != null && properties.getPropagation().getType().contains(PropagationType.W3C)) { throw new IncompatibleConfigurationException("management.tracing.propagation.type", - "management.tracing.brave.span-joining-supported"); + SPAN_JOINING); } if (properties.getPropagation().getType() == null && properties.getPropagation().getProduce().contains(PropagationType.W3C)) { throw new IncompatibleConfigurationException("management.tracing.propagation.produce", - "management.tracing.brave.span-joining-supported"); + SPAN_JOINING); } if (properties.getPropagation().getType() == null && properties.getPropagation().getConsume().contains(PropagationType.W3C)) { throw new IncompatibleConfigurationException("management.tracing.propagation.consume", - "management.tracing.brave.span-joining-supported"); + SPAN_JOINING); } } String applicationName = environment.getProperty("spring.application.name", DEFAULT_APPLICATION_NAME); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerAdapter.java index 0ea1923820ff..2531546057ed 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerAdapter.java @@ -63,6 +63,9 @@ public ModelAndView handle(HttpServletRequest request, HttpServletResponse respo @Override @Deprecated(since = "2.4.9", forRemoval = false) @SuppressWarnings("deprecation") + /** + * @deprecated since 2.4.9 + */ public long getLastModified(HttpServletRequest request, Object handler) { Optional adapter = getAdapter(handler); return adapter.map((handlerAdapter) -> handlerAdapter.getLastModified(request, handler)).orElse(0L); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java index b120533b2dbe..aa6861c2bc4c 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java @@ -160,7 +160,7 @@ protected HotSpotDiagnosticMXBeanHeapDumper() { this.dumpHeapMethod = ReflectionUtils.findMethod(diagnosticMXBeanClass, "dumpHeap", String.class, Boolean.TYPE); } - catch (Throwable ex) { + catch (Exception ex) { throw new HeapDumperUnavailableException("Unable to locate HotSpotDiagnosticMXBean", ex); } } @@ -202,7 +202,7 @@ private OpenJ9DiagnosticsMXBeanHeapDumper() { this.dumpHeapMethod = ReflectionUtils.findMethod(mxBeanClass, "triggerDumpToFile", String.class, String.class); } - catch (Throwable ex) { + catch (Exception ex) { throw new HeapDumperUnavailableException("Unable to locate OpenJ9DiagnosticsMXBean", ex); } } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManager.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManager.java index dc3ebe4d31ac..2b296ee70f59 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManager.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManager.java @@ -105,7 +105,7 @@ private void post() { try { this.pushGateway.pushAdd(this.registry, this.job, this.groupingKey); } - catch (Throwable ex) { + catch (Exception ex) { logger.warn("Unexpected exception thrown by POST of metrics to Prometheus Pushgateway", ex); } } @@ -114,7 +114,7 @@ private void put() { try { this.pushGateway.push(this.registry, this.job, this.groupingKey); } - catch (Throwable ex) { + catch (Exception ex) { logger.warn("Unexpected exception thrown by PUT of metrics to Prometheus Pushgateway", ex); } } @@ -123,7 +123,7 @@ private void delete() { try { this.pushGateway.delete(this.job, this.groupingKey); } - catch (Throwable ex) { + catch (Exception ex) { logger.warn("Unexpected exception thrown by DELETE of metrics from Prometheus Pushgateway", ex); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java index bd9fb0daa0ea..1d924f8fcb7d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java @@ -82,8 +82,7 @@ protected static class RabbitConnectionFactoryCreator { private final RabbitProperties properties; - protected RabbitConnectionFactoryCreator(RabbitProperties properties, - ObjectProvider connectionDetails) { + protected RabbitConnectionFactoryCreator(RabbitProperties properties) { this.properties = properties; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherApplicationRunner.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherApplicationRunner.java index b4415ac365ef..e95e7386d5f0 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherApplicationRunner.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherApplicationRunner.java @@ -186,22 +186,18 @@ private boolean isRegisteredJob(String jobName) { private void executeLocalJobs(JobParameters jobParameters) throws JobExecutionException { for (Job job : this.jobs) { - if (StringUtils.hasText(this.jobName)) { - if (!this.jobName.equals(job.getName())) { - logger.debug(LogMessage.format("Skipped job: %s", job.getName())); - continue; - } + if (StringUtils.hasText(this.jobName) && !this.jobName.equals(job.getName())) { + logger.debug(LogMessage.format("Skipped job: %s", job.getName())); + continue; } execute(job, jobParameters); } } private void executeRegisteredJobs(JobParameters jobParameters) throws JobExecutionException { - if (this.jobRegistry != null && StringUtils.hasText(this.jobName)) { - if (!isLocalJob(this.jobName)) { - Job job = this.jobRegistry.getJob(this.jobName); - execute(job, jobParameters); - } + if (this.jobRegistry != null && StringUtils.hasText(this.jobName) && !isLocalJob(this.jobName)) { + Job job = this.jobRegistry.getJob(this.jobName); + execute(job, jobParameters); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ResourceCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ResourceCondition.java index a4461fee8068..6426c69c8828 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ResourceCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ResourceCondition.java @@ -75,7 +75,7 @@ protected ConditionOutcome getResourceOutcome(ConditionContext context, Annotate List found = new ArrayList<>(); for (String location : this.resourceLocations) { Resource resource = context.getResourceLoader().getResource(location); - if (resource != null && resource.exists()) { + if (resource.exists()) { found.add(location); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java index d1e93181c570..299729934a77 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java @@ -182,11 +182,17 @@ public void setEnabled(Boolean enabled) { @DeprecatedConfigurationProperty( reason = "SSL bundle support with spring.ssl.bundle and spring.couchbase.env.ssl.bundle should be used instead", since = "3.1.0") + /** + * @deprecated since 3.1.0 + */ public String getKeyStore() { return this.keyStore; } @Deprecated(since = "3.1.0", forRemoval = true) + /** + * @deprecated since 3.1.0 + */ public void setKeyStore(String keyStore) { this.keyStore = keyStore; } @@ -195,11 +201,17 @@ public void setKeyStore(String keyStore) { @DeprecatedConfigurationProperty( reason = "SSL bundle support with spring.ssl.bundle and spring.couchbase.env.ssl.bundle should be used instead", since = "3.1.0") + /** + * @deprecated since 3.1.0 + */ public String getKeyStorePassword() { return this.keyStorePassword; } @Deprecated(since = "3.1.0", forRemoval = true) + /** + * @deprecated since 3.1.0 + */ public void setKeyStorePassword(String keyStorePassword) { this.keyStorePassword = keyStorePassword; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java index 10d5f2159614..dbebd68da992 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java @@ -63,6 +63,7 @@ class NoSuchBeanDefinitionFailureAnalyzer extends AbstractInjectionFailureAnalyz private final MetadataReaderFactory metadataReaderFactory; private final ConditionEvaluationReport report; + private final String FORMAT_PATTERN = "\t- %s%n"; NoSuchBeanDefinitionFailureAnalyzer(BeanFactory beanFactory) { Assert.isInstanceOf(ConfigurableListableBeanFactory.class, beanFactory); @@ -88,17 +89,17 @@ protected FailureAnalysis analyze(Throwable rootFailure, NoSuchBeanDefinitionExc if (injectionAnnotations.length > 0) { message.append(String.format("%nThe injection point has the following annotations:%n")); for (Annotation injectionAnnotation : injectionAnnotations) { - message.append(String.format("\t- %s%n", injectionAnnotation)); + message.append(String.format(FORMAT_PATTERN, injectionAnnotation)); } } } if (!autoConfigurationResults.isEmpty() || !userConfigurationResults.isEmpty()) { message.append(String.format("%nThe following candidates were found but could not be injected:%n")); for (AutoConfigurationResult result : autoConfigurationResults) { - message.append(String.format("\t- %s%n", result)); + message.append(String.format(FORMAT_PATTERN, result)); } for (UserConfigurationResult result : userConfigurationResults) { - message.append(String.format("\t- %s%n", result)); + message.append(String.format(FORMAT_PATTERN, result)); } } String action = String.format("Consider %s %s in your configuration.", diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java index 4a6d7db6e0ca..b0a333681b98 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java @@ -738,33 +738,51 @@ public void setLicenseKey(String licenseKey) { @DeprecatedConfigurationProperty(replacement = "spring.flyway.oracle.sqlplus", since = "3.2.0") @Deprecated(since = "3.2.0", forRemoval = true) + /** + * @deprecated since 3.2.0 + */ public Boolean getOracleSqlplus() { return getOracle().getSqlplus(); } @Deprecated(since = "3.2.0", forRemoval = true) + /** + * @deprecated since 3.2.0 + */ public void setOracleSqlplus(Boolean oracleSqlplus) { getOracle().setSqlplus(oracleSqlplus); } @DeprecatedConfigurationProperty(replacement = "spring.flyway.oracle.sqlplus-warn", since = "3.2.0") @Deprecated(since = "3.2.0", forRemoval = true) + /** + * @deprecated since 3.2.0 + */ public Boolean getOracleSqlplusWarn() { return getOracle().getSqlplusWarn(); } @Deprecated(since = "3.2.0", forRemoval = true) + /** + * @deprecated since 3.2.0 + */ public void setOracleSqlplusWarn(Boolean oracleSqlplusWarn) { getOracle().setSqlplusWarn(oracleSqlplusWarn); } @DeprecatedConfigurationProperty(replacement = "spring.flyway.oracle.wallet-location", since = "3.2.0") @Deprecated(since = "3.2.0", forRemoval = true) + /** + * @deprecated since 3.2.0 + */ public String getOracleWalletLocation() { return getOracle().getWalletLocation(); } @Deprecated(since = "3.2.0", forRemoval = true) + /** + * @deprecated since 3.2.0 + */ public void setOracleWalletLocation(String oracleWalletLocation) { getOracle().setWalletLocation(oracleWalletLocation); } @@ -811,11 +829,17 @@ public void setKerberosConfigFile(String kerberosConfigFile) { @DeprecatedConfigurationProperty(replacement = "spring.flyway.oracle.kerberos-cache-file", since = "3.2.0") @Deprecated(since = "3.2.0", forRemoval = true) + /** + * @deprecated since 3.2.0 + */ public String getOracleKerberosCacheFile() { return getOracle().getKerberosCacheFile(); } @Deprecated(since = "3.2.0", forRemoval = true) + /** + * @deprecated since 3.2.0 + */ public void setOracleKerberosCacheFile(String oracleKerberosCacheFile) { getOracle().setKerberosCacheFile(oracleKerberosCacheFile); } @@ -830,11 +854,17 @@ public void setOutputQueryResults(Boolean outputQueryResults) { @DeprecatedConfigurationProperty(replacement = "spring.flyway.sqlserver.kerberos-login-file") @Deprecated(since = "3.2.0", forRemoval = true) + /** + * @deprecated since 3.2.0 + */ public String getSqlServerKerberosLoginFile() { return getSqlserver().getKerberosLoginFile(); } @Deprecated(since = "3.2.0", forRemoval = true) + /** + * @deprecated since 3.2.0 + */ public void setSqlServerKerberosLoginFile(String sqlServerKerberosLoginFile) { getSqlserver().setKerberosLoginFile(sqlServerKerberosLoginFile); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxDbAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxDbAutoConfiguration.java index 904541755a4b..c5ffc06594cf 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxDbAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxDbAutoConfiguration.java @@ -55,7 +55,7 @@ public class InfluxDbAutoConfiguration { @ConditionalOnMissingBean public InfluxDB influxDb(InfluxDbProperties properties, ObjectProvider builder, ObjectProvider customizers) { - InfluxDB influxDb = new InfluxDBImpl(properties.getUrl().toString(), properties.getUser(), + InfluxDB influxDb = new InfluxDBImpl(properties.getUrl(), properties.getUser(), properties.getPassword(), determineBuilder(builder.getIfAvailable())); customizers.orderedStream().forEach((customizer) -> customizer.customize(influxDb)); return influxDb; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java index 7227df43f233..909c36ec3f08 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java @@ -840,11 +840,17 @@ public void setBootstrapServers(List bootstrapServers) { @DeprecatedConfigurationProperty(replacement = "spring.kafka.streams.state-store-cache-max-size", since = "3.1.0") @Deprecated(since = "3.1.0", forRemoval = true) + /** + * @deprecated since 3.1.0 + */ public DataSize getCacheMaxSizeBuffering() { return this.cacheMaxSizeBuffering; } @Deprecated(since = "3.1.0", forRemoval = true) + /** + * @deprecated since 3.1.0 + */ public void setCacheMaxSizeBuffering(DataSize cacheMaxSizeBuffering) { this.cacheMaxSizeBuffering = cacheMaxSizeBuffering; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index e8742b414f6a..d34a45eaf365 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -464,7 +464,10 @@ public static class Tomcat { /** * Whether to reject requests with illegal header names or values. */ - @Deprecated(since = "2.7.12", forRemoval = true) // Remove in 3.3 + @Deprecated(since = "2.7.12", forRemoval = true) + /** + * @deprecated since 2.7.12 for removal in 3.3 + */ private boolean rejectIllegalHeader = true; /** @@ -625,11 +628,17 @@ public void setConnectionTimeout(Duration connectionTimeout) { @Deprecated(since = "3.2.0", forRemoval = true) @DeprecatedConfigurationProperty(reason = "The setting has been deprecated in Tomcat", since = "3.2.0") + /** + * @deprecated since 3.2.0 + */ public boolean isRejectIllegalHeader() { return this.rejectIllegalHeader; } @Deprecated(since = "3.2.0", forRemoval = true) + /** + * @deprecated since 3.2.0 + */ public void setRejectIllegalHeader(boolean rejectIllegalHeader) { this.rejectIllegalHeader = rejectIllegalHeader; } @@ -1638,11 +1647,17 @@ public void setMaxCookies(Integer maxCookies) { @DeprecatedConfigurationProperty(replacement = "server.undertow.decode-slash", since = "3.0.3") @Deprecated(forRemoval = true, since = "3.0.3") + /** + * @deprecated since 3.0.3 + */ public boolean isAllowEncodedSlash() { return this.allowEncodedSlash; } @Deprecated(forRemoval = true, since = "3.0.3") + /** + * @deprecated since 3.0.3 + */ public void setAllowEncodedSlash(boolean allowEncodedSlash) { this.allowEncodedSlash = allowEncodedSlash; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java index afdf35f65091..37337f36479a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java @@ -128,11 +128,17 @@ public void setPublishRequestHandledEvents(boolean publishRequestHandledEvents) @DeprecatedConfigurationProperty( reason = "DispatcherServlet property is deprecated for removal and should no longer need to be configured", since = "3.2.0") + /** + * @deprecated since 3.2.0 + */ public boolean isThrowExceptionIfNoHandlerFound() { return this.throwExceptionIfNoHandlerFound; } @Deprecated(since = "3.2.0", forRemoval = true) + /** + * @deprecated since 3.2.0 + */ public void setThrowExceptionIfNoHandlerFound(boolean throwExceptionIfNoHandlerFound) { this.throwExceptionIfNoHandlerFound = throwExceptionIfNoHandlerFound; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WelcomePageNotAcceptableHandlerMapping.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WelcomePageNotAcceptableHandlerMapping.java index d96a5428f17e..7344c28cab53 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WelcomePageNotAcceptableHandlerMapping.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WelcomePageNotAcceptableHandlerMapping.java @@ -50,9 +50,4 @@ private ModelAndView handleRequest(HttpServletRequest request, HttpServletRespon return null; } - @Override - protected Object getHandlerInternal(HttpServletRequest request) throws Exception { - return super.getHandlerInternal(request); - } - } diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/Restarter.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/Restarter.java index 410b269d1d66..0935ab7c1e2a 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/Restarter.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/Restarter.java @@ -316,8 +316,6 @@ protected void stop() throws Exception { finally { this.stopLock.unlock(); } - System.gc(); - System.runFinalization(); } private void cleanupCaches() { @@ -344,7 +342,7 @@ private void clearAnnotationUtilsCache() { try { AnnotationUtils.clearCache(); } - catch (Throwable ex) { + catch (Exception ex) { clear(AnnotationUtils.class, "findAnnotationCache"); clear(AnnotationUtils.class, "annotatedInterfaceCache"); } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/appendix/configurationmetadata/format/property/MyProperties.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/appendix/configurationmetadata/format/property/MyProperties.java index b4247ff30699..b2e8cd8dc632 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/appendix/configurationmetadata/format/property/MyProperties.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/appendix/configurationmetadata/format/property/MyProperties.java @@ -34,11 +34,17 @@ public void setName(String name) { @Deprecated @DeprecatedConfigurationProperty(replacement = "my.app.name") + /** + * @deprecated + */ public String getTarget() { return this.name; } @Deprecated + /** + * @deprecated + */ public void setTarget(String target) { this.name = target; } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/LogUpdateEvent.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/LogUpdateEvent.java index ecaf8c8485e4..44f7e0b3caa0 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/LogUpdateEvent.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/LogUpdateEvent.java @@ -20,6 +20,8 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.function.Consumer; +import java.util.logging.Level; +import java.util.logging.Logger; import java.util.regex.Pattern; import org.springframework.util.Assert; @@ -53,9 +55,12 @@ public class LogUpdateEvent extends UpdateEvent { } public void print() { + Logger logger + = Logger.getLogger( + LogUpdateEvent.class.getName()); switch (this.streamType) { - case STD_OUT -> System.out.println(this); - case STD_ERR -> System.err.println(this); + case STD_OUT -> logger.log(Level.INFO, this.toString()); + case STD_ERR -> logger.log(Level.SEVERE, this.toString()); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/ConfigurationMetadataRepositoryJsonBuilder.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/ConfigurationMetadataRepositoryJsonBuilder.java index cfd08488d083..a334b0e8d240 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/ConfigurationMetadataRepositoryJsonBuilder.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/ConfigurationMetadataRepositoryJsonBuilder.java @@ -67,10 +67,8 @@ public ConfigurationMetadataRepositoryJsonBuilder withJsonResource(InputStream i * @param inputStream the source input stream * @param charset the charset of the input * @return this builder - * @throws IOException in case of I/O errors */ - public ConfigurationMetadataRepositoryJsonBuilder withJsonResource(InputStream inputStream, Charset charset) - throws IOException { + public ConfigurationMetadataRepositoryJsonBuilder withJsonResource(InputStream inputStream, Charset charset){ if (inputStream == null) { throw new IllegalArgumentException("InputStream must not be null."); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptor.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptor.java index 83cc34704225..a13dc69c1978 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptor.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptor.java @@ -176,7 +176,7 @@ private boolean isParentTheSame(MetadataGenerationEnvironment environment, Eleme } returnType = getTopLevelType(returnType); Element candidate = element; - while (candidate != null && candidate instanceof TypeElement) { + while (candidate instanceof TypeElement) { if (returnType.equals(getTopLevelType(candidate))) { return true; } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java index 8661345e9efc..ee605ffed533 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java @@ -49,7 +49,7 @@ public class JarWriter extends AbstractJarWriter implements AutoCloseable { * @throws IOException if the file cannot be opened * @throws FileNotFoundException if the file cannot be found */ - public JarWriter(File file) throws FileNotFoundException, IOException { + public JarWriter(File file) throws IOException { this(file, null); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java index 3703ac136705..5b3c233df03c 100755 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java @@ -35,6 +35,8 @@ import java.util.Properties; import java.util.Set; import java.util.jar.Manifest; +import java.util.logging.Level; +import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -487,7 +489,10 @@ private static String capitalize(String str) { private void debug(String message) { if (Boolean.getBoolean(DEBUG)) { - System.out.println(message); + Logger logger + = Logger.getLogger( + PropertiesLauncher.class.getName()); + logger.log(Level.INFO, message); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/ExplodedArchive.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/ExplodedArchive.java index 08734078520c..b43503f57eb1 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/ExplodedArchive.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/ExplodedArchive.java @@ -104,6 +104,9 @@ public Iterator getNestedArchives(EntryFilter searchFilter, EntryFilter @Override @Deprecated(since = "2.3.10", forRemoval = false) + /** + * @deprecated since 2.3.10 + */ public Iterator iterator() { return new EntryIterator(this.root, this.recursive, null, null); } @@ -323,6 +326,9 @@ public Iterator getNestedArchives(EntryFilter searchFilter, EntryFilter @Override @Deprecated(since = "2.3.10", forRemoval = false) + /** + * @deprecated since 2.3.10 + */ public Iterator iterator() { return Collections.emptyIterator(); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java index 67bf8048f046..d3b849833e39 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java @@ -214,7 +214,10 @@ private void log(boolean warning, String message, Exception cause) { } catch (Exception ex) { if (warning) { - System.err.println("WARNING: " + message); + Logger logger + = Logger.getLogger( + Handler.class.getName()); + logger.log(Level.SEVERE, "WARNING: " + message); } } } @@ -444,7 +447,7 @@ private static boolean canResetCachedUrlHandlers() { resetCachedUrlHandlers(); return true; } - catch (Error ex) { + catch (Exception ex) { return false; } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java index b6f0e3a3a7fb..8ebf14d4d5f0 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java @@ -20,6 +20,8 @@ import java.util.Locale; import java.util.Properties; import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; /** * Helper class for resolving placeholders in texts. Usually applied to file paths. @@ -188,8 +190,11 @@ public static String getProperty(String key, String defaultValue, String text) { return propVal; } } - catch (Throwable ex) { - System.err.println("Could not resolve key '" + key + "' in '" + text + catch (Exception ex) { + Logger logger + = Logger.getLogger( + SystemPropertyUtils.class.getName()); + logger.log(Level.SEVERE, "Could not resolve key '" + key + "' in '" + text + "' as system property or in environment: " + ex); } return defaultValue; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index 69f42ed0eac2..5e4aa464e257 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -25,6 +25,8 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -321,7 +323,7 @@ public ConfigurableApplicationContext run(String... args) { listeners.started(context, timeTakenToStartup); callRunners(context, applicationArguments); } - catch (Throwable ex) { + catch (Exception ex) { if (ex instanceof AbandonedRunException) { throw ex; } @@ -334,7 +336,7 @@ public ConfigurableApplicationContext run(String... args) { listeners.ready(context, timeTakenToReady); } } - catch (Throwable ex) { + catch (Exception ex) { if (ex instanceof AbandonedRunException) { throw ex; } @@ -806,7 +808,7 @@ private Collection getExceptionReporters(Configurab ArgumentResolver argumentResolver = ArgumentResolver.of(ConfigurableApplicationContext.class, context); return getSpringFactoriesInstances(SpringBootExceptionReporter.class, argumentResolver); } - catch (Throwable ex) { + catch (Exception ex) { return Collections.emptyList(); } } @@ -820,7 +822,7 @@ private void reportFailure(Collection exceptionRepo } } } - catch (Throwable ex) { + catch (Exception ex) { // Continue with normal handling of the original failure } if (logger.isErrorEnabled()) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java index 4f8e98e1e6ff..10b32ba156ef 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java @@ -22,6 +22,7 @@ import java.util.List; import java.util.Map; import java.util.function.Function; +import java.util.function.UnaryOperator; import org.springframework.util.Assert; import org.springframework.util.StringUtils; @@ -672,7 +673,7 @@ public static ConfigurationPropertyName adapt(CharSequence name, char separator) * @return a {@link ConfigurationPropertyName} */ static ConfigurationPropertyName adapt(CharSequence name, char separator, - Function elementValueProcessor) { + UnaryOperator elementValueProcessor) { Assert.notNull(name, "Name must not be null"); if (name.length() == 0) { return EMPTY; @@ -916,7 +917,7 @@ Elements parse() { return parse(null); } - Elements parse(Function valueProcessor) { + Elements parse(UnaryOperator valueProcessor) { int length = this.source.length(); int openBracketCount = 0; int start = 0; @@ -977,7 +978,7 @@ private ElementType updateType(ElementType existingType, char ch, int index) { return existingType; } - private void add(int start, int end, ElementType type, Function valueProcessor) { + private void add(int start, int end, ElementType type, UnaryOperator valueProcessor) { if ((end - start) < 1 || type == ElementType.EMPTY) { return; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/NoSuchMethodFailureAnalyzer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/NoSuchMethodFailureAnalyzer.java index 16ea0e5d3691..c14fa4d1ab04 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/NoSuchMethodFailureAnalyzer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/NoSuchMethodFailureAnalyzer.java @@ -118,7 +118,7 @@ private List findCandidates(String className) { return Collections.list(NoSuchMethodFailureAnalyzer.class.getClassLoader() .getResources(ClassUtils.convertClassNameToResourcePath(className) + ".class")); } - catch (Throwable ex) { + catch (Exception ex) { return null; } } @@ -127,7 +127,7 @@ private Class load(String className) { try { return Class.forName(className, false, getClass().getClassLoader()); } - catch (Throwable ex) { + catch (Exception ex) { return null; } } @@ -142,7 +142,7 @@ private List getTypeHierarchy(Class type) { } return typeHierarchy; } - catch (Throwable ex) { + catch (Exception ex) { return null; } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilder.java index 60cc940a8409..07272ef6131a 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilder.java @@ -20,6 +20,7 @@ import java.lang.reflect.Method; import java.sql.SQLException; import java.util.Collections; +import java.util.EnumMap; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -89,7 +90,7 @@ public final class DataSourceBuilder { private final ClassLoader classLoader; - private final Map values = new HashMap<>(); + private final EnumMap values = new EnumMap<>(DataSourceProperty.class); private Class type; @@ -338,7 +339,7 @@ static DataSourceProperties forType(ClassLoader classL private static class MappedDataSourceProperties implements DataSourceProperties { - private final Map> mappedProperties = new HashMap<>(); + private final EnumMap> mappedProperties = new EnumMap<>(DataSourceProperty.class); private final Class dataSourceType; @@ -530,8 +531,8 @@ private static class ReflectionDataSourceProperties implem ReflectionDataSourceProperties(Class dataSourceType) { Assert.state(dataSourceType != null, "No supported DataSource type found"); - Map getters = new HashMap<>(); - Map setters = new HashMap<>(); + EnumMap getters = new EnumMap<>(DataSourceProperty.class); + EnumMap setters = new EnumMap<>(DataSourceProperty.class); for (DataSourceProperty property : DataSourceProperty.values()) { putIfNotNull(getters, property, property.findGetter(dataSourceType)); putIfNotNull(setters, property, property.findSetter(dataSourceType)); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/CorrelationIdFormatter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/CorrelationIdFormatter.java index 1388aecca0b6..cf89f0cba87f 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/CorrelationIdFormatter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/CorrelationIdFormatter.java @@ -24,6 +24,7 @@ import java.util.List; import java.util.function.Function; import java.util.function.Predicate; +import java.util.function.UnaryOperator; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -84,7 +85,7 @@ private CorrelationIdFormatter(List parts) { * @param resolver the resolver used to resolve named values * @return a formatted correlation id */ - public String format(Function resolver) { + public String format(UnaryOperator resolver) { StringBuilder result = new StringBuilder(); formatTo(resolver, result); return result.toString(); @@ -96,7 +97,7 @@ public String format(Function resolver) { * @param resolver the resolver used to resolve named values * @param appendable the appendable for the formatted correlation id */ - public void formatTo(Function resolver, Appendable appendable) { + public void formatTo(UnaryOperator resolver, Appendable appendable) { Predicate canResolve = (part) -> StringUtils.hasLength(resolver.apply(part.name())); try { if (this.parts.stream().anyMatch(canResolve)) { @@ -169,7 +170,7 @@ record Part(String name, int length) { private static final Pattern pattern = Pattern.compile("^(.+?)\\((\\d+)\\)$"); - String resolve(Function resolver) { + String resolve(UnaryOperator resolver) { String resolved = resolver.apply(name()); if (resolved == null) { return blank(); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java index 10152f88c398..fcc6bd0df42d 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java @@ -186,7 +186,7 @@ && isLog4jBridgeHandlerAvailable()) { return true; } } - catch (Throwable ex) { + catch (Exception ex) { // Ignore. No java.util.logging bridge is installed. } return false; @@ -226,7 +226,7 @@ private void removeDefaultRootHandler() { rootLogger.removeHandler(handlers[0]); } } - catch (Throwable ex) { + catch (Exception ex) { // Ignore and continue } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java index 668ec8375b72..a30c8254ffe1 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java @@ -137,7 +137,7 @@ private void configureJdkLoggingBridgeHandler() { SLF4JBridgeHandler.install(); } } - catch (Throwable ex) { + catch (Exception ex) { // Ignore. No java.util.logging bridge is installed. } } @@ -161,7 +161,7 @@ private void removeJdkLoggingBridgeHandler() { removeDefaultRootHandler(); SLF4JBridgeHandler.uninstall(); } - catch (Throwable ex) { + catch (Exception ex) { // Ignore and continue } } @@ -174,7 +174,7 @@ private void removeDefaultRootHandler() { rootLogger.removeHandler(handlers[0]); } } - catch (Throwable ex) { + catch (Exception ex) { // Ignore and continue } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/SystemProperties.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/SystemProperties.java index fb32a3053460..a3d2ac60289c 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/SystemProperties.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/SystemProperties.java @@ -16,6 +16,9 @@ package org.springframework.boot.system; +import java.util.logging.Level; +import java.util.logging.Logger; + /** * Access to system properties. * @@ -36,8 +39,11 @@ public static String get(String... properties) { return override; } } - catch (Throwable ex) { - System.err.println("Could not resolve '" + property + "' as system property: " + ex); + catch (Exception ex) { + Logger logger + = Logger.getLogger( + SystemProperties.class.getName()); + logger.log(Level.SEVERE, "Could not resolve '" + property + "' as system property: " + ex); } } return null; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContext.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContext.java index d6513792d21b..9822a2d648f5 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContext.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContext.java @@ -161,7 +161,7 @@ protected void onRefresh() { try { createWebServer(); } - catch (Throwable ex) { + catch (Exception ex) { throw new ApplicationContextException("Unable to start web server", ex); } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/ErrorPageFilter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/ErrorPageFilter.java index a4a4d813c462..ccc3ab0b783d 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/ErrorPageFilter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/ErrorPageFilter.java @@ -130,7 +130,7 @@ else if (!request.isAsyncStarted() && !response.isCommitted()) { response.flushBuffer(); } } - catch (Throwable ex) { + catch (Exception ex) { Throwable exceptionToHandle = ex; if (ex instanceof ServletException servletException) { Throwable rootCause = servletException.getRootCause(); @@ -303,7 +303,7 @@ private static void addClassIfPresent(Collection> collection, String cl try { collection.add(ClassUtils.forName(className, null)); } - catch (Throwable ex) { + catch (Exception ignored) { } } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-bootstrap-registry/src/main/java/smoketest/bootstrapregistry/app/Printer.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-bootstrap-registry/src/main/java/smoketest/bootstrapregistry/app/Printer.java index d9f7d1c75953..2bbe54aa748c 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-bootstrap-registry/src/main/java/smoketest/bootstrapregistry/app/Printer.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-bootstrap-registry/src/main/java/smoketest/bootstrapregistry/app/Printer.java @@ -16,6 +16,9 @@ package smoketest.bootstrapregistry.app; +import java.util.logging.Level; +import java.util.logging.Logger; + import smoketest.bootstrapregistry.external.svn.SubversionClient; import org.springframework.beans.factory.annotation.Value; @@ -25,8 +28,11 @@ public class Printer { Printer(@Value("${svn}") String svn, SubversionClient subversionClient) { - System.out.println("--- svn " + svn); - System.out.println("--- client " + subversionClient.getClass().getName()); + Logger logger + = Logger.getLogger( + Printer.class.getName()); + logger.log(Level.INFO, "--- svn " + svn); + logger.log(Level.INFO, "--- client " + subversionClient.getClass().getName()); } } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-ldap/src/main/java/smoketest/data/ldap/SampleLdapApplication.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-ldap/src/main/java/smoketest/data/ldap/SampleLdapApplication.java index cc574fd6c3c4..68fadaf7df8b 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-ldap/src/main/java/smoketest/data/ldap/SampleLdapApplication.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-ldap/src/main/java/smoketest/data/ldap/SampleLdapApplication.java @@ -16,6 +16,8 @@ package smoketest.data.ldap; +import java.util.logging.Level; +import java.util.logging.Logger; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -31,19 +33,21 @@ public SampleLdapApplication(PersonRepository repository) { @Override public void run(String... args) throws Exception { - + Logger logger + = Logger.getLogger( + SampleLdapApplication.class.getName()); // fetch all people - System.out.println("People found with findAll():"); - System.out.println("-------------------------------"); + logger.log(Level.INFO, "People found with findAll():"); + logger.log(Level.INFO, "-------------------------------"); for (Person person : this.repository.findAll()) { - System.out.println(person); + logger.log(Level.INFO, person.toString()); } - System.out.println(); + logger.log(Level.INFO, ""); // fetch an individual person - System.out.println("Person found with findByPhone('+46 555-123456'):"); - System.out.println("--------------------------------"); - System.out.println(this.repository.findByPhone("+46 555-123456")); + logger.log(Level.INFO, "Person found with findByPhone('+46 555-123456'):"); + logger.log(Level.INFO, "--------------------------------"); + logger.log(Level.INFO, this.repository.findByPhone("+46 555-123456").toString()); } public static void main(String[] args) { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty/src/main/java/smoketest/jetty/ExampleServletContextListener.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty/src/main/java/smoketest/jetty/ExampleServletContextListener.java index c8d355535023..bca7fd950068 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty/src/main/java/smoketest/jetty/ExampleServletContextListener.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty/src/main/java/smoketest/jetty/ExampleServletContextListener.java @@ -16,6 +16,9 @@ package smoketest.jetty; +import java.util.logging.Level; +import java.util.logging.Logger; + import jakarta.servlet.ServletContextEvent; import jakarta.servlet.ServletContextListener; @@ -29,12 +32,18 @@ public class ExampleServletContextListener implements ServletContextListener { @Override public void contextInitialized(ServletContextEvent sce) { - System.out.println("*** contextInitialized"); + Logger logger + = Logger.getLogger( + ExampleServletContextListener.class.getName()); + logger.log(Level.INFO, "*** contextInitialized"); } @Override public void contextDestroyed(ServletContextEvent sce) { - System.out.println("*** contextDestroyed"); + Logger logger + = Logger.getLogger( + ExampleServletContextListener.class.getName()); + logger.log(Level.INFO, "*** contextDestroyed"); } } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-property-validation/src/main/java/smoketest/propertyvalidation/SamplePropertyValidationApplication.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-property-validation/src/main/java/smoketest/propertyvalidation/SamplePropertyValidationApplication.java index a3bfabaf1990..611dc743cc24 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-property-validation/src/main/java/smoketest/propertyvalidation/SamplePropertyValidationApplication.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-property-validation/src/main/java/smoketest/propertyvalidation/SamplePropertyValidationApplication.java @@ -16,6 +16,9 @@ package smoketest.propertyvalidation; +import java.util.logging.Level; +import java.util.logging.Logger; + import org.springframework.boot.CommandLineRunner; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; @@ -40,10 +43,13 @@ public static Validator configurationPropertiesValidator() { @Override public void run(String... args) { - System.out.println("========================================="); - System.out.println("Sample host: " + this.properties.getHost()); - System.out.println("Sample port: " + this.properties.getPort()); - System.out.println("========================================="); + Logger logger + = Logger.getLogger( + SamplePropertyValidationApplication.class.getName()); + logger.log(Level.INFO, "========================================="); + logger.log(Level.INFO, "Sample host: " + this.properties.getHost()); + logger.log(Level.INFO, "Sample port: " + this.properties.getPort()); + logger.log(Level.INFO, "========================================="); } public static void main(String[] args) { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/SnakeTimer.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/SnakeTimer.java index 2a8924fcbd44..a240a63812ad 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/SnakeTimer.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/SnakeTimer.java @@ -86,7 +86,7 @@ public static void broadcast(String message) { try { snake.sendMessage(message); } - catch (Throwable ex) { + catch (Exception ex) { // if Snake#sendMessage fails the client is removed removeSnake(snake); } @@ -101,7 +101,7 @@ public void run() { try { tick(); } - catch (Throwable ex) { + catch (Exception ex) { logger.error("Caught to prevent timer from shutting down", ex); } } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/SnakeTimer.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/SnakeTimer.java index 82be974569e3..3969743b3bbe 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/SnakeTimer.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/SnakeTimer.java @@ -86,7 +86,7 @@ public static void broadcast(String message) { try { snake.sendMessage(message); } - catch (Throwable ex) { + catch (Exception ex) { // if Snake#sendMessage fails the client is removed removeSnake(snake); } @@ -101,7 +101,7 @@ public void run() { try { tick(); } - catch (Throwable ex) { + catch (Exception ex) { logger.error("Caught to prevent timer from shutting down", ex); } } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeTimer.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeTimer.java index 1b044c018bee..a41ef24783e3 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeTimer.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeTimer.java @@ -86,7 +86,7 @@ public static void broadcast(String message) { try { snake.sendMessage(message); } - catch (Throwable ex) { + catch (Exception ex) { // if Snake#sendMessage fails the client is removed removeSnake(snake); } @@ -101,7 +101,7 @@ public void run() { try { tick(); } - catch (Throwable ex) { + catch (Exception ex) { logger.error("Caught to prevent timer from shutting down", ex); } }