From 4d15ee5bf09dcf08cd7969de773e77b98f782fd3 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Fri, 13 Dec 2024 23:40:38 +0900 Subject: [PATCH] Polish See gh-43498 --- CONTRIBUTING.adoc | 2 +- .../boot/build/bom/CheckBom.java | 2 +- .../OnEnabledLoggingExportCondition.java | 5 +- .../test/resources/batch/custom-schema.sql | 66 +++++++++---------- .../reference/pages/io/rest-client.adoc | 4 +- .../MyClientHttpConfiguration.kt | 2 +- .../json/app/ExampleJsonComponent.java | 2 +- .../json/JSONObject.java | 2 +- .../boot/util/Instantiator.java | 6 +- .../boot/web/client/RestTemplateBuilder.java | 2 +- ...PortInfoApplicationContextInitializer.java | 4 +- ...verContainerInvocationContextProvider.java | 5 +- 12 files changed, 52 insertions(+), 50 deletions(-) diff --git a/CONTRIBUTING.adoc b/CONTRIBUTING.adoc index 6e09addf884c..a8ff958ac9ff 100755 --- a/CONTRIBUTING.adoc +++ b/CONTRIBUTING.adoc @@ -43,7 +43,7 @@ None of these is essential for a pull request, but they will all help. They can added after the original pull request but before a merge. * We use the https://github.com/spring-io/spring-javaformat/[Spring JavaFormat] project to apply code formatting conventions. - If you use Eclipse and you follow the https://github.com/spring-projects/spring-boot/wiki/Working-with-the-Code#importing-into-eclipse["Importing into eclipse"] instructions you should get project specific formatting automatically. + If you use Eclipse and you follow the https://github.com/spring-projects/spring-boot/wiki/Working-with-the-Code#importing-into-eclipse["Importing into Eclipse"] instructions you should get project-specific formatting automatically. You can also install the https://github.com/spring-io/spring-javaformat/#intellij-idea[Spring JavaFormat IntelliJ Plugin] or format the code from the Gradle build by running `./gradlew format`. Note that if you have format violations in `buildSrc`, you can fix them by running `./gradlew -p buildSrc format` from the project root directory. * The build includes Checkstyle rules for many of our code conventions. Run `./gradlew checkstyleMain checkstyleTest` if you want to check your changes are compliant. diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/CheckBom.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/CheckBom.java index 250aa5d559ef..365e67c6784c 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/CheckBom.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/CheckBom.java @@ -216,7 +216,7 @@ private File resolveBom(Library library, String alignsWithBom) { .getResolvedConfiguration() .getResolvedArtifacts(); if (artifacts.size() != 1) { - throw new IllegalStateException("Expected a single file but '%s' resolved to %d artifacts" + throw new IllegalStateException("Expected a single artifact but '%s' resolved to %d artifacts" .formatted(coordinates, artifacts.size())); } return artifacts.iterator().next().getFile(); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/OnEnabledLoggingExportCondition.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/OnEnabledLoggingExportCondition.java index eb328c816525..dbd22e9efe78 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/OnEnabledLoggingExportCondition.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/OnEnabledLoggingExportCondition.java @@ -42,12 +42,13 @@ class OnEnabledLoggingExportCondition extends SpringBootCondition { public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { String loggingExporter = getExporterName(metadata); if (StringUtils.hasLength(loggingExporter)) { + String formattedExporterProperty = EXPORTER_PROPERTY.formatted(loggingExporter); Boolean exporterLoggingEnabled = context.getEnvironment() - .getProperty(EXPORTER_PROPERTY.formatted(loggingExporter), Boolean.class); + .getProperty(formattedExporterProperty, Boolean.class); if (exporterLoggingEnabled != null) { return new ConditionOutcome(exporterLoggingEnabled, ConditionMessage.forCondition(ConditionalOnEnabledLoggingExport.class) - .because(EXPORTER_PROPERTY.formatted(loggingExporter) + " is " + exporterLoggingEnabled)); + .because(formattedExporterProperty + " is " + exporterLoggingEnabled)); } } Boolean globalLoggingEnabled = context.getEnvironment().getProperty(GLOBAL_PROPERTY, Boolean.class); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/batch/custom-schema.sql b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/batch/custom-schema.sql index 5953b5c47959..2181b1132579 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/batch/custom-schema.sql +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/batch/custom-schema.sql @@ -1,21 +1,21 @@ CREATE TABLE PREFIX_JOB_INSTANCE ( - JOB_INSTANCE_ID BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY , - VERSION BIGINT , + JOB_INSTANCE_ID BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, + VERSION BIGINT, JOB_NAME VARCHAR(100) NOT NULL, JOB_KEY VARCHAR(32) NOT NULL, constraint JOB_INST_UN unique (JOB_NAME, JOB_KEY) ) ; CREATE TABLE PREFIX_JOB_EXECUTION ( - JOB_EXECUTION_ID BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY , - VERSION BIGINT , + JOB_EXECUTION_ID BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, + VERSION BIGINT, JOB_INSTANCE_ID BIGINT NOT NULL, CREATE_TIME TIMESTAMP NOT NULL, - START_TIME TIMESTAMP DEFAULT NULL , - END_TIME TIMESTAMP DEFAULT NULL , - STATUS VARCHAR(10) , - EXIT_CODE VARCHAR(2500) , - EXIT_MESSAGE VARCHAR(2500) , + START_TIME TIMESTAMP DEFAULT NULL, + END_TIME TIMESTAMP DEFAULT NULL, + STATUS VARCHAR(10), + EXIT_CODE VARCHAR(2500), + EXIT_MESSAGE VARCHAR(2500), LAST_UPDATED TIMESTAMP, JOB_CONFIGURATION_LOCATION VARCHAR(2500) NULL, constraint JOB_INST_EXEC_FK foreign key (JOB_INSTANCE_ID) @@ -23,36 +23,36 @@ CREATE TABLE PREFIX_JOB_EXECUTION ( ) ; CREATE TABLE PREFIX_JOB_EXECUTION_PARAMS ( - JOB_EXECUTION_ID BIGINT NOT NULL , - TYPE_CD VARCHAR(6) NOT NULL , - KEY_NAME VARCHAR(100) NOT NULL , - STRING_VAL VARCHAR(250) , - DATE_VAL TIMESTAMP DEFAULT NULL , - LONG_VAL BIGINT , - DOUBLE_VAL DOUBLE PRECISION , - IDENTIFYING CHAR(1) NOT NULL , + JOB_EXECUTION_ID BIGINT NOT NULL, + TYPE_CD VARCHAR(6) NOT NULL, + KEY_NAME VARCHAR(100) NOT NULL, + STRING_VAL VARCHAR(250), + DATE_VAL TIMESTAMP DEFAULT NULL, + LONG_VAL BIGINT, + DOUBLE_VAL DOUBLE PRECISION, + IDENTIFYING CHAR(1) NOT NULL, constraint JOB_EXEC_PARAMS_FK foreign key (JOB_EXECUTION_ID) references PREFIX_JOB_EXECUTION(JOB_EXECUTION_ID) ) ; CREATE TABLE PREFIX_STEP_EXECUTION ( - STEP_EXECUTION_ID BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY , + STEP_EXECUTION_ID BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, VERSION BIGINT NOT NULL, STEP_NAME VARCHAR(100) NOT NULL, JOB_EXECUTION_ID BIGINT NOT NULL, - START_TIME TIMESTAMP NOT NULL , - END_TIME TIMESTAMP DEFAULT NULL , - STATUS VARCHAR(10) , - COMMIT_COUNT BIGINT , - READ_COUNT BIGINT , - FILTER_COUNT BIGINT , - WRITE_COUNT BIGINT , - READ_SKIP_COUNT BIGINT , - WRITE_SKIP_COUNT BIGINT , - PROCESS_SKIP_COUNT BIGINT , - ROLLBACK_COUNT BIGINT , - EXIT_CODE VARCHAR(2500) , - EXIT_MESSAGE VARCHAR(2500) , + START_TIME TIMESTAMP NOT NULL, + END_TIME TIMESTAMP DEFAULT NULL, + STATUS VARCHAR(10), + COMMIT_COUNT BIGINT, + READ_COUNT BIGINT, + FILTER_COUNT BIGINT, + WRITE_COUNT BIGINT, + READ_SKIP_COUNT BIGINT, + WRITE_SKIP_COUNT BIGINT, + PROCESS_SKIP_COUNT BIGINT, + ROLLBACK_COUNT BIGINT, + EXIT_CODE VARCHAR(2500), + EXIT_MESSAGE VARCHAR(2500), LAST_UPDATED TIMESTAMP, constraint JOB_EXEC_STEP_FK foreign key (JOB_EXECUTION_ID) references PREFIX_JOB_EXECUTION(JOB_EXECUTION_ID) @@ -61,7 +61,7 @@ CREATE TABLE PREFIX_STEP_EXECUTION ( CREATE TABLE PREFIX_STEP_EXECUTION_CONTEXT ( STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY, SHORT_CONTEXT VARCHAR(2500) NOT NULL, - SERIALIZED_CONTEXT LONGVARCHAR , + SERIALIZED_CONTEXT LONGVARCHAR, constraint STEP_EXEC_CTX_FK foreign key (STEP_EXECUTION_ID) references PREFIX_STEP_EXECUTION(STEP_EXECUTION_ID) ) ; @@ -69,7 +69,7 @@ CREATE TABLE PREFIX_STEP_EXECUTION_CONTEXT ( CREATE TABLE PREFIX_JOB_EXECUTION_CONTEXT ( JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY, SHORT_CONTEXT VARCHAR(2500) NOT NULL, - SERIALIZED_CONTEXT LONGVARCHAR , + SERIALIZED_CONTEXT LONGVARCHAR, constraint JOB_EXEC_CTX_FK foreign key (JOB_EXECUTION_ID) references PREFIX_JOB_EXECUTION(JOB_EXECUTION_ID) ) ; diff --git a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/io/rest-client.adoc b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/io/rest-client.adoc index 40fac8b9a484..6fbbf6dbaed8 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/io/rest-client.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/io/rest-client.adoc @@ -209,8 +209,8 @@ If multiple clients are available on the classpath, and not global configuration [[io.rest-client.clienthttprequestfactory.configuration]] === Global HTTP Client Configuration -If the the auto-detected HTTP client does not meet your needs, you can use the configprop:spring.http.client.factory[] property to pick a specific factory. -For example, if you have Apache HttpClient on your classpath, but you prefer Jetty's javadoc:org.eclipse.jetty.client.HttpClient[] you can add use the following: +If the auto-detected HTTP client does not meet your needs, you can use the configprop:spring.http.client.factory[] property to pick a specific factory. +For example, if you have Apache HttpClient on your classpath, but you prefer Jetty's javadoc:org.eclipse.jetty.client.HttpClient[] you can add the following: [configprops,yaml] ---- diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/clienthttprequestfactory/configuration/MyClientHttpConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/clienthttprequestfactory/configuration/MyClientHttpConfiguration.kt index d3a7827b109c..9ffd8489c677 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/clienthttprequestfactory/configuration/MyClientHttpConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/clienthttprequestfactory/configuration/MyClientHttpConfiguration.kt @@ -10,7 +10,7 @@ import java.net.http.HttpClient class MyClientHttpConfiguration { @Bean - fun clientHttpRequestFactoryBuilder(proxySelector: ProxySelector): ClientHttpRequestFactoryBuilder<*>? { + fun clientHttpRequestFactoryBuilder(proxySelector: ProxySelector): ClientHttpRequestFactoryBuilder<*> { return ClientHttpRequestFactoryBuilder.jdk() .withHttpClientCustomizer { builder -> builder.proxy(proxySelector) } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonComponent.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonComponent.java index 3cb4698f56a4..3817f7d98249 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonComponent.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonComponent.java @@ -59,7 +59,7 @@ static class Deserializer extends JsonObjectDeserializer { protected ExampleCustomObject deserializeObject(JsonParser jsonParser, DeserializationContext context, ObjectCodec codec, JsonNode tree) throws IOException { String value = nullSafeValue(tree.get("value"), String.class); - Date date = nullSafeValue(tree.get("date"), Integer.class, Date::new); + Date date = nullSafeValue(tree.get("date"), Long.class, Date::new); UUID uuid = nullSafeValue(tree.get("uuid"), String.class, UUID::fromString); return new ExampleCustomObject(value, date, uuid); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONObject.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONObject.java index acf177a7508e..8bb808fff37c 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONObject.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONObject.java @@ -786,7 +786,7 @@ public static String quote(String data) { /** * Wraps the given object if necessary. *

- * If the object is null or , returns {@link #NULL}. If the object is a + * If the object is null or, returns {@link #NULL}. If the object is a * {@code JSONArray} or {@code JSONObject}, no wrapping is necessary. If the object is * {@code NULL}, no wrapping is necessary. If the object is an array or * {@code Collection}, returns an equivalent {@code JSONArray}. If the object is a diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/util/Instantiator.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/util/Instantiator.java index b752e86a77a8..87d2d300d433 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/util/Instantiator.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/util/Instantiator.java @@ -149,9 +149,9 @@ public T instantiate(ClassLoader classLoader, String name) { } /** - * Instantiate the given set of classes, injecting constructor arguments as necessary. - * @param type the types to instantiate - * @return a list of instantiated instances + * Instantiate the given class, injecting constructor arguments as necessary. + * @param type the type to instantiate + * @return an instantiated instance * @since 3.4.0 */ public T instantiateType(Class type) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java index 5c9821e7dcf1..3862e9c0d04d 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java @@ -438,7 +438,7 @@ this.errorHandler, this.basicAuthentication, append(this.defaultHeaders, name, v /** * Sets the {@link ClientHttpRequestFactorySettings}. This will replace any previously - * set {@link #connectTimeout(Duration) connectTimeout} ,{@link #readTimeout(Duration) + * set {@link #connectTimeout(Duration) connectTimeout}, {@link #readTimeout(Duration) * readTimeout} and {@link #sslBundle(SslBundle) sslBundle} values. * @param requestFactorySettings the request factory settings * @return a new builder instance diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/context/ServerPortInfoApplicationContextInitializer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/context/ServerPortInfoApplicationContextInitializer.java index 2ec73ab57a12..80394628a08c 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/context/ServerPortInfoApplicationContextInitializer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/context/ServerPortInfoApplicationContextInitializer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 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. @@ -39,7 +39,7 @@ * {@link Value @Value} or obtained through the {@link Environment}. *

* If the {@link WebServerInitializedEvent} has a - * {@link WebServerApplicationContext#getServerNamespace() server namespace} , it will be + * {@link WebServerApplicationContext#getServerNamespace() server namespace}, it will be * used to construct the property name. For example, the "management" actuator context * will have the property name {@literal "local.management.port"}. *

diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/intTest/java/org/springframework/boot/context/embedded/EmbeddedServerContainerInvocationContextProvider.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/intTest/java/org/springframework/boot/context/embedded/EmbeddedServerContainerInvocationContextProvider.java index 4ed867e3ee03..c7328fc8a203 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/intTest/java/org/springframework/boot/context/embedded/EmbeddedServerContainerInvocationContextProvider.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/intTest/java/org/springframework/boot/context/embedded/EmbeddedServerContainerInvocationContextProvider.java @@ -116,8 +116,9 @@ private void cleanupCaches() { private AbstractApplicationLauncher getAbstractApplicationLauncher(Application application, Class launcherClass) { String cacheKey = application.getContainer() + ":" + application.getPackaging() + ":" + launcherClass.getName(); - if (this.launcherCache.containsKey(cacheKey)) { - return this.launcherCache.get(cacheKey); + AbstractApplicationLauncher cachedLauncher = this.launcherCache.get(cacheKey); + if (cachedLauncher != null) { + return cachedLauncher; } AbstractApplicationLauncher launcher = ReflectionUtils.newInstance(launcherClass, application, new File(buildOutput.getRootLocation(), "app-launcher-" + UUID.randomUUID()));