Polish 'Remove unreachable throw code'

See gh-39107
This commit is contained in:
Phillip Webb
2024-01-16 11:35:13 -08:00
parent a4ae6600ef
commit e23e431f10

View File

@@ -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 {
listeners.ready(context, timeTakenToReady);
}
}
catch (AbandonedRunException ex) {
throw ex;
}
catch (Throwable ex) {
throw handleRunFailure(context, ex, null);
}
@@ -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 {
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) {