@ -376,8 +376,19 @@ public class SpringApplication {
protected void handleError ( ConfigurableApplicationContext context ,
protected void handleError ( ConfigurableApplicationContext context ,
ApplicationEventMulticaster multicaster , Throwable ex , String . . . args ) {
ApplicationEventMulticaster multicaster , Throwable ex , String . . . args ) {
multicaster . multicastEvent ( new SpringApplicationErrorEvent ( this , context , args ,
try {
ex ) ) ;
multicaster . multicastEvent ( new SpringApplicationErrorEvent ( this , context ,
args , ex ) ) ;
}
catch ( Exception e ) {
// We don't want to fail here and mask the original exception
if ( this . log . isDebugEnabled ( ) ) {
this . log . error ( "Error handling failed" , e ) ;
}
else {
this . log . warn ( "Error handling failed (" + e . getMessage ( ) + ")" ) ;
}
}
if ( context ! = null ) {
if ( context ! = null ) {
context . close ( ) ;
context . close ( ) ;
}
}
@ -1004,8 +1015,8 @@ public class SpringApplication {
@Override
@Override
protected Collection < ApplicationListener < ? > > getApplicationListeners (
protected Collection < ApplicationListener < ? > > getApplicationListeners (
ApplicationEvent event ) {
ApplicationEvent event ) {
List < ApplicationListener < ? > > listeners = new ArrayList < ApplicationListener < ? > > (
List < ApplicationListener < ? > > listeners = new ArrayList < ApplicationListener < ? > > ( ) ;
super . getApplicationListeners ( event ) ) ;
listeners . addAll ( super . getApplicationListeners ( event ) ) ;
if ( event instanceof SpringApplicationErrorEvent ) {
if ( event instanceof SpringApplicationErrorEvent ) {
Collections . reverse ( listeners ) ;
Collections . reverse ( listeners ) ;
}
}