Ensure SpringApplication closes its ApplicationContext

...even if the CommandLineRunners fail and we drop to the error
handling path.

Fixes gh-211
pull/234/head
Dave Syer 11 years ago
parent 420fc69983
commit c349cb66ba

@ -360,18 +360,25 @@ public class SpringApplication {
return context;
}
catch (RuntimeException ex) {
multicaster.multicastEvent(new SpringApplicationErrorEvent(this, context,
args, ex));
handleError(context, multicaster, ex, args);
throw ex;
}
catch (Error ex) {
multicaster.multicastEvent(new SpringApplicationErrorEvent(this, context,
args, ex));
handleError(context, multicaster, ex, args);
throw ex;
}
}
protected void handleError(ConfigurableApplicationContext context,
ApplicationEventMulticaster multicaster, Throwable ex, String... args) {
multicaster.multicastEvent(new SpringApplicationErrorEvent(this, context, args,
ex));
if (context != null) {
context.close();
}
}
private void registerListeners(ApplicationEventMulticaster multicaster,
Set<Object> sources) {
for (Object object : sources) {

Loading…
Cancel
Save