diff --git a/core/spring-boot/src/main/java/org/springframework/boot/DefaultApplicationArguments.java b/core/spring-boot/src/main/java/org/springframework/boot/DefaultApplicationArguments.java index e2ea20c32ea..190aa8dcab0 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/DefaultApplicationArguments.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/DefaultApplicationArguments.java @@ -16,9 +16,7 @@ package org.springframework.boot; -import java.util.Arrays; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Set; @@ -53,7 +51,7 @@ public String[] getSourceArgs() { @Override public Set getOptionNames() { String[] names = this.source.getPropertyNames(); - return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(names))); + return Set.of(names); } @Override diff --git a/core/spring-boot/src/main/java/org/springframework/boot/EnvironmentConverter.java b/core/spring-boot/src/main/java/org/springframework/boot/EnvironmentConverter.java index dacf5bc9304..880b35da108 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/EnvironmentConverter.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/EnvironmentConverter.java @@ -17,7 +17,6 @@ package org.springframework.boot; import java.lang.reflect.Constructor; -import java.util.Collections; import java.util.HashSet; import java.util.Set; @@ -44,11 +43,9 @@ final class EnvironmentConverter { private static final Set SERVLET_ENVIRONMENT_SOURCE_NAMES; static { - Set names = new HashSet<>(); - names.add(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME); - names.add(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME); - names.add(StandardServletEnvironment.JNDI_PROPERTY_SOURCE_NAME); - SERVLET_ENVIRONMENT_SOURCE_NAMES = Collections.unmodifiableSet(names); + SERVLET_ENVIRONMENT_SOURCE_NAMES = Set.of(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME, + StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME, + StandardServletEnvironment.JNDI_PROPERTY_SOURCE_NAME); } private final ClassLoader classLoader; diff --git a/core/spring-boot/src/main/java/org/springframework/boot/ExitCodeGenerators.java b/core/spring-boot/src/main/java/org/springframework/boot/ExitCodeGenerators.java index 9c29dfd8284..b55202266f8 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/ExitCodeGenerators.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/ExitCodeGenerators.java @@ -41,12 +41,6 @@ class ExitCodeGenerators implements Iterable { private final List generators = new ArrayList<>(); - void addAll(Throwable exception, ExitCodeExceptionMapper... mappers) { - Assert.notNull(exception, "'exception' must not be null"); - Assert.notNull(mappers, "'mappers' must not be null"); - addAll(exception, Arrays.asList(mappers)); - } - void addAll(Throwable exception, Iterable mappers) { Assert.notNull(exception, "'exception' must not be null"); Assert.notNull(mappers, "'mappers' must not be null"); diff --git a/core/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListeners.java b/core/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListeners.java index 522fec60684..42aa6de6831 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListeners.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListeners.java @@ -28,7 +28,6 @@ import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.metrics.ApplicationStartup; import org.springframework.core.metrics.StartupStep; -import org.springframework.util.ReflectionUtils; /** * A collection of {@link SpringApplicationRunListener}. @@ -99,9 +98,6 @@ private void callFailedListener(SpringApplicationRunListener listener, listener.failed(context, exception); } catch (Throwable ex) { - if (exception == null) { - ReflectionUtils.rethrowRuntimeException(ex); - } if (this.log.isDebugEnabled()) { this.log.error("Error handling failed", ex); } diff --git a/core/spring-boot/src/main/java/org/springframework/boot/SpringBootExceptionHandler.java b/core/spring-boot/src/main/java/org/springframework/boot/SpringBootExceptionHandler.java index b29ed796ab5..b01c98c4cec 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/SpringBootExceptionHandler.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/SpringBootExceptionHandler.java @@ -19,8 +19,6 @@ import java.lang.Thread.UncaughtExceptionHandler; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Set; @@ -34,13 +32,7 @@ */ class SpringBootExceptionHandler implements UncaughtExceptionHandler { - private static final Set LOG_CONFIGURATION_MESSAGES; - - static { - Set messages = new HashSet<>(); - messages.add("Logback configuration error detected"); - LOG_CONFIGURATION_MESSAGES = Collections.unmodifiableSet(messages); - } + private static final Set LOG_CONFIGURATION_MESSAGES = Set.of("Logback configuration error detected"); private static final LoggedExceptionHandlerThreadLocal handler = new LoggedExceptionHandlerThreadLocal();