diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ssl/SslPropertiesBundleRegistrar.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ssl/SslPropertiesBundleRegistrar.java index 531fb8d574..810ff772a3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ssl/SslPropertiesBundleRegistrar.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ssl/SslPropertiesBundleRegistrar.java @@ -16,8 +16,6 @@ package org.springframework.boot.autoconfigure.ssl; -import java.io.FileNotFoundException; -import java.io.UncheckedIOException; import java.net.URL; import java.nio.file.Path; import java.util.LinkedHashSet; @@ -106,10 +104,10 @@ class SslPropertiesBundleRegistrar implements SslBundleRegistrar { URL url = ResourceUtils.getURL(value); Assert.state("file".equalsIgnoreCase(url.getProtocol()), () -> "SSL bundle '%s' '%s' URL '%s' doesn't point to a file".formatted(bundleName, field, url)); - return Path.of(url.getFile()).toAbsolutePath(); + return Path.of(url.toURI()).toAbsolutePath(); } - catch (FileNotFoundException ex) { - throw new UncheckedIOException( + catch (Exception ex) { + throw new RuntimeException( "SSL bundle '%s' '%s' location '%s' cannot be watched".formatted(bundleName, field, value), ex); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ssl/FileWatcherTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ssl/FileWatcherTests.java index e680479d0e..ef09b28481 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ssl/FileWatcherTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ssl/FileWatcherTests.java @@ -111,7 +111,7 @@ class FileWatcherTests { Path directory = tempDir.resolve("dir1"); assertThatExceptionOfType(UncheckedIOException.class) .isThrownBy(() -> this.fileWatcher.watch(Set.of(directory), new WaitingCallback())) - .withMessageMatching("Failed to register paths for watching: \\[.+/dir1]"); + .withMessage("Failed to register paths for watching: [%s]".formatted(directory)); } @Test