From f1957a9740dd7a3bdb22a93428fb36b30d390916 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 10 Nov 2025 09:24:39 +0000 Subject: [PATCH] Address warnings reported by Eclipse --- .../pulsar/PulsarReactiveAutoConfiguration.java | 3 --- ...bServerFactoryCustomizerAutoConfiguration.java | 5 ++--- ...yVirtualThreadsWebServerFactoryCustomizer.java | 12 ++++++++++-- ...ualThreadsWebServerFactoryCustomizerTests.java | 5 +---- .../gradle/tasks/bundling/BootZipCopyAction.java | 15 ++++++++------- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarReactiveAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarReactiveAutoConfiguration.java index e36d0a47b90..614096d95f9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarReactiveAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarReactiveAutoConfiguration.java @@ -72,12 +72,9 @@ import org.springframework.pulsar.reactive.listener.ReactivePulsarContainerPrope @Import(PulsarConfiguration.class) public class PulsarReactiveAutoConfiguration { - private final PulsarProperties properties; - private final PulsarReactivePropertiesMapper propertiesMapper; PulsarReactiveAutoConfiguration(PulsarProperties properties) { - this.properties = properties; this.propertiesMapper = new PulsarReactivePropertiesMapper(properties); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/EmbeddedWebServerFactoryCustomizerAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/EmbeddedWebServerFactoryCustomizerAutoConfiguration.java index 2655d2b17f4..6ea7d99bf43 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/EmbeddedWebServerFactoryCustomizerAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/EmbeddedWebServerFactoryCustomizerAutoConfiguration.java @@ -91,9 +91,8 @@ public class EmbeddedWebServerFactoryCustomizerAutoConfiguration { @Bean @ConditionalOnThreading(Threading.VIRTUAL) - JettyVirtualThreadsWebServerFactoryCustomizer jettyVirtualThreadsWebServerFactoryCustomizer( - ServerProperties serverProperties) { - return new JettyVirtualThreadsWebServerFactoryCustomizer(serverProperties); + JettyVirtualThreadsWebServerFactoryCustomizer jettyVirtualThreadsWebServerFactoryCustomizer() { + return new JettyVirtualThreadsWebServerFactoryCustomizer(); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/JettyVirtualThreadsWebServerFactoryCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/JettyVirtualThreadsWebServerFactoryCustomizer.java index 73ead24c331..740ae7113f1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/JettyVirtualThreadsWebServerFactoryCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/JettyVirtualThreadsWebServerFactoryCustomizer.java @@ -35,10 +35,18 @@ import org.springframework.util.Assert; public class JettyVirtualThreadsWebServerFactoryCustomizer implements WebServerFactoryCustomizer, Ordered { - private final ServerProperties serverProperties; + public JettyVirtualThreadsWebServerFactoryCustomizer() { + } + + /** + * Create a new JettyVirtualThreadsWebServerFactoryCustomizer. + * @param serverProperties server properties + * @deprecated since 3.4.12 for removal in 4.0.0 in favor of + * {@link JettyVirtualThreadsWebServerFactoryCustomizer}. + */ + @Deprecated(since = "3.4.12", forRemoval = true) public JettyVirtualThreadsWebServerFactoryCustomizer(ServerProperties serverProperties) { - this.serverProperties = serverProperties; } @Override diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyVirtualThreadsWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyVirtualThreadsWebServerFactoryCustomizerTests.java index e89e822402c..dff16454854 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyVirtualThreadsWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyVirtualThreadsWebServerFactoryCustomizerTests.java @@ -21,7 +21,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledForJreRange; import org.junit.jupiter.api.condition.JRE; -import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.web.embedded.jetty.ConfigurableJettyWebServerFactory; import static org.assertj.core.api.Assertions.assertThat; @@ -39,9 +38,7 @@ class JettyVirtualThreadsWebServerFactoryCustomizerTests { @Test @EnabledForJreRange(min = JRE.JAVA_21) void shouldConfigureVirtualThreads() { - ServerProperties properties = new ServerProperties(); - JettyVirtualThreadsWebServerFactoryCustomizer customizer = new JettyVirtualThreadsWebServerFactoryCustomizer( - properties); + JettyVirtualThreadsWebServerFactoryCustomizer customizer = new JettyVirtualThreadsWebServerFactoryCustomizer(); ConfigurableJettyWebServerFactory factory = mock(ConfigurableJettyWebServerFactory.class); customizer.customize(factory); then(factory).should().setThreadPool(assertArg((threadPool) -> { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java index 7eeadbd84c8..254c1edbc1d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java @@ -67,6 +67,7 @@ import org.springframework.boot.loader.tools.ReachabilityMetadataProperties; import org.springframework.util.Assert; import org.springframework.util.StreamUtils; import org.springframework.util.StringUtils; +import org.springframework.util.function.ThrowingSupplier; /** * A {@link CopyAction} for creating a Spring Boot zip archive (typically a jar or war). @@ -349,7 +350,7 @@ class BootZipCopyAction implements CopyAction { private void writeJarModeLibrary(String location, JarModeLibrary library) throws IOException { String name = location + library.getName(); writeEntry(name, ZipEntryContentWriter.fromInputStream(library.openStream()), false, - (entry) -> prepareStoredEntry(library.openStream(), false, entry)); + (entry) -> prepareStoredEntry(library::openStream, false, entry)); if (BootZipCopyAction.this.layerResolver != null) { Layer layer = BootZipCopyAction.this.layerResolver.getLayer(library); this.layerIndex.add(layer, name); @@ -447,12 +448,12 @@ class BootZipCopyAction implements CopyAction { } private void prepareStoredEntry(FileCopyDetails details, ZipArchiveEntry archiveEntry) throws IOException { - prepareStoredEntry(details.open(), BootZipCopyAction.this.requiresUnpack.isSatisfiedBy(details), + prepareStoredEntry(details::open, BootZipCopyAction.this.requiresUnpack.isSatisfiedBy(details), archiveEntry); } - private void prepareStoredEntry(InputStream input, boolean unpack, ZipArchiveEntry archiveEntry) - throws IOException { + private void prepareStoredEntry(ThrowingSupplier input, boolean unpack, + ZipArchiveEntry archiveEntry) throws IOException { new StoredEntryPreparator(input, unpack).prepareStoredEntry(archiveEntry); } @@ -578,10 +579,10 @@ class BootZipCopyAction implements CopyAction { private long size; - StoredEntryPreparator(InputStream inputStream, boolean unpack) throws IOException { + StoredEntryPreparator(ThrowingSupplier input, boolean unpack) throws IOException { this.messageDigest = (unpack) ? sha1Digest() : null; - try (inputStream) { - load(inputStream); + try (InputStream stream = input.get()) { + load(stream); } }