diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/sbom/SbomEndpointWebExtension.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/sbom/SbomEndpointWebExtension.java index 422895ec3fae..f2396c13120f 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/sbom/SbomEndpointWebExtension.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/sbom/SbomEndpointWebExtension.java @@ -17,7 +17,6 @@ package org.springframework.boot.actuate.sbom; import java.io.IOException; -import java.io.UncheckedIOException; import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -29,6 +28,7 @@ import org.springframework.boot.actuate.sbom.SbomProperties.Sbom; import org.springframework.core.io.Resource; import org.springframework.util.MimeType; +import org.springframework.util.function.ThrowingFunction; /** * {@link EndpointWebExtension @EndpointWebExtension} for the {@link SbomEndpoint}. @@ -68,14 +68,9 @@ private MimeType getMediaType(String id, Resource resource) { if (sbomProperties != null && sbomProperties.getMediaType() != null) { return sbomProperties.getMediaType(); } - return this.detectedMediaTypeCache.computeIfAbsent(id, (ignored) -> { - try { - return detectSbomType(resource); - } - catch (IOException ex) { - throw new UncheckedIOException("Failed to detect type of resource '%s'".formatted(resource), ex); - } - }).getMediaType(); + return this.detectedMediaTypeCache + .computeIfAbsent(id, (ThrowingFunction) (ignored) -> detectSbomType(resource)) + .getMediaType(); } private SbomType detectSbomType(Resource resource) throws IOException { 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..f3a4224f2388 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,13 +116,8 @@ 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 launcher = ReflectionUtils.newInstance(launcherClass, application, - new File(buildOutput.getRootLocation(), "app-launcher-" + UUID.randomUUID())); - this.launcherCache.put(cacheKey, launcher); - return launcher; + return this.launcherCache.computeIfAbsent(cacheKey, (ignored) -> ReflectionUtils.newInstance(launcherClass, + application, new File(buildOutput.getRootLocation(), "app-launcher-" + UUID.randomUUID()))); } private Application getApplication(EmbeddedServletContainerTest annotation, String container) {