End StartupSteps only once in SpringApplicationRunListeners

Fixes gh-22776
pull/22834/head
Brian Clozel 4 years ago
parent e240c180f3
commit 9343266c4f

@ -111,7 +111,6 @@ class SpringApplicationRunListeners {
StartupStep step = this.applicationStartup.start(stepName);
this.listeners.forEach(listenerAction);
stepAction.accept(step);
step.end();
}
}

@ -122,6 +122,7 @@ import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.willThrow;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockingDetails;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@ -1171,6 +1172,11 @@ class SpringApplicationTests {
verify(applicationStartup).start("spring.boot.application.context-loaded");
verify(applicationStartup).start("spring.boot.application.started");
verify(applicationStartup).start("spring.boot.application.running");
long startCount = mockingDetails(applicationStartup).getInvocations().stream()
.filter((invocation) -> invocation.getMethod().toString().contains("start(")).count();
long endCount = mockingDetails(startupStep).getInvocations().stream()
.filter((invocation) -> invocation.getMethod().toString().contains("end(")).count();
assertThat(startCount).isEqualTo(endCount);
}
private <S extends AvailabilityState> ArgumentMatcher<ApplicationEvent> isAvailabilityChangeEventWithState(

Loading…
Cancel
Save