diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/util/LambdaSafe.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/util/LambdaSafe.java index 04bd7c8430..ad4cf2e092 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/util/LambdaSafe.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/util/LambdaSafe.java @@ -286,12 +286,11 @@ public final class LambdaSafe { * @param invoker the invoker used to invoke the callback */ public void invoke(Consumer invoker) { - Function> mapper = (callbackInstance) -> invoke( - callbackInstance, () -> { - invoker.accept(callbackInstance); - return null; - }); - this.callbackInstances.stream().map(mapper).forEach((result) -> { + this.callbackInstances.forEach((callbackInstance) -> { + invoke(callbackInstance, () -> { + invoker.accept(callbackInstance); + return null; + }); }); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java index dcd0e22dc2..46aa264046 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java @@ -354,11 +354,13 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac File docBase = getCanonicalDocumentRoot(root); List metaInfResourceUrls = getUrlsOfJarsWithMetaInfResources(); List resourceJarUrls = new ArrayList<>(); - List resourceManagers = new ArrayList<>(); - ResourceManager rootResourceManager = (docBase.isDirectory() + List managers = new ArrayList<>(); + ResourceManager rootManager = (docBase.isDirectory() ? new FileResourceManager(docBase, 0) : new JarResourceManager(docBase)); - resourceManagers.add(root == null ? rootResourceManager - : new LoaderHidingResourceManager(rootResourceManager)); + if (root != null) { + rootManager = new LoaderHidingResourceManager(rootManager); + } + managers.add(rootManager); for (URL url : metaInfResourceUrls) { if ("file".equals(url.getProtocol())) { try { @@ -367,7 +369,7 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac resourceJarUrls.add(new URL("jar:" + url + "!/")); } else { - resourceManagers.add(new FileResourceManager( + managers.add(new FileResourceManager( new File(file, "META-INF/resources"), 0)); } } @@ -379,9 +381,8 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac resourceJarUrls.add(url); } } - resourceManagers.add(new MetaInfResourcesResourceManager(resourceJarUrls)); - return new CompositeResourceManager( - resourceManagers.toArray(new ResourceManager[0])); + managers.add(new MetaInfResourcesResourceManager(resourceJarUrls)); + return new CompositeResourceManager(managers.toArray(new ResourceManager[0])); } private File getCanonicalDocumentRoot(File docBase) {