Publish ApplicationPreparedEvent before AOT processing abandons run

pull/32488/head
Andy Wilkinson 2 years ago
parent afce559050
commit 26eff5ae7a

@ -456,7 +456,7 @@ public class SpringApplication {
SpringApplicationRunListener hookListener = (hook != null) ? hook.getRunListener(this) : null;
if (hookListener != null) {
listeners = new ArrayList<>(listeners);
listeners.add(0, hookListener);
listeners.add(hookListener);
}
return new SpringApplicationRunListeners(logger, listeners, this.applicationStartup);
}

@ -1302,8 +1302,11 @@ class SpringApplicationTests {
}
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
void withHookWhenHookThrowsAbandonedRunExceptionAbandonsRun() {
SpringApplication application = new SpringApplication(ExampleConfig.class);
ApplicationListener listener = mock(ApplicationListener.class);
application.addListeners(listener);
application.setWebApplicationType(WebApplicationType.NONE);
SpringApplicationRunListener runListener = spy(new SpringApplicationRunListener() {
@ -1321,6 +1324,11 @@ class SpringApplicationTests {
then(runListener).should().contextPrepared(any());
then(runListener).should(never()).ready(any(), any());
then(runListener).should(never()).failed(any(), any());
then(listener).should().onApplicationEvent(any(ApplicationStartingEvent.class));
then(listener).should().onApplicationEvent(any(ApplicationEnvironmentPreparedEvent.class));
then(listener).should().onApplicationEvent(any(ApplicationPreparedEvent.class));
then(listener).should(never()).onApplicationEvent(any(ApplicationReadyEvent.class));
then(listener).should(never()).onApplicationEvent(any(ApplicationFailedEvent.class));
}
@Test

Loading…
Cancel
Save