Browse Source

Polish 'Remove unreachable throw code'

See gh-39107
pull/39395/head
Phillip Webb 2 years ago
parent
commit
e23e431f10
  1. 15
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java

15
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java

@ -330,9 +330,6 @@ public class SpringApplication { @@ -330,9 +330,6 @@ public class SpringApplication {
listeners.started(context, timeTakenToStartup);
callRunners(context, applicationArguments);
}
catch (AbandonedRunException ex) {
throw ex;
}
catch (Throwable ex) {
throw handleRunFailure(context, ex, listeners);
}
@ -342,9 +339,6 @@ public class SpringApplication { @@ -342,9 +339,6 @@ public class SpringApplication {
listeners.ready(context, timeTakenToReady);
}
}
catch (AbandonedRunException ex) {
throw ex;
}
catch (Throwable ex) {
throw handleRunFailure(context, ex, null);
}
@ -790,6 +784,9 @@ public class SpringApplication { @@ -790,6 +784,9 @@ public class SpringApplication {
private RuntimeException handleRunFailure(ConfigurableApplicationContext context, Throwable exception,
SpringApplicationRunListeners listeners) {
if (exception instanceof AbandonedRunException abandonedRunException) {
return abandonedRunException;
}
try {
try {
handleExitCode(context, exception);
@ -808,10 +805,8 @@ public class SpringApplication { @@ -808,10 +805,8 @@ public class SpringApplication {
catch (Exception ex) {
logger.warn("Unable to close ApplicationContext", ex);
}
if (exception instanceof RuntimeException runtimeException) {
return runtimeException;
}
return new IllegalStateException(exception);
return (exception instanceof RuntimeException runtimeException) ? runtimeException
: new IllegalStateException(exception);
}
private Collection<SpringBootExceptionReporter> getExceptionReporters(ConfigurableApplicationContext context) {

Loading…
Cancel
Save