See gh-28494
pull/28497/head
izeye 3 years ago committed by Stephane Nicoll
parent 51dc02e37b
commit 5d8dce70dc

@ -900,7 +900,7 @@ public class RabbitProperties {
* Whether the container will support listeners that consume native stream * Whether the container will support listeners that consume native stream
* messages instead of Spring AMQP messages. * messages instead of Spring AMQP messages.
*/ */
boolean nativeListener; private boolean nativeListener;
public boolean isNativeListener() { public boolean isNativeListener() {
return this.nativeListener; return this.nativeListener;

@ -18,7 +18,7 @@ package org.springframework.boot.autoconfigure.condition.scan;
public class ScanBean { public class ScanBean {
private String value; private final String value;
public ScanBean(String value) { public ScanBean(String value) {
this.value = value; this.value = value;

@ -301,11 +301,11 @@ public class SpringApplication {
prepareContext(bootstrapContext, context, environment, listeners, applicationArguments, printedBanner); prepareContext(bootstrapContext, context, environment, listeners, applicationArguments, printedBanner);
refreshContext(context); refreshContext(context);
afterRefresh(context, applicationArguments); afterRefresh(context, applicationArguments);
Duration timeTakeToStartup = Duration.ofNanos(System.nanoTime() - startTime); Duration timeTakenToStartup = Duration.ofNanos(System.nanoTime() - startTime);
if (this.logStartupInfo) { if (this.logStartupInfo) {
new StartupInfoLogger(this.mainApplicationClass).logStarted(getApplicationLog(), timeTakeToStartup); new StartupInfoLogger(this.mainApplicationClass).logStarted(getApplicationLog(), timeTakenToStartup);
} }
listeners.started(context, timeTakeToStartup); listeners.started(context, timeTakenToStartup);
callRunners(context, applicationArguments); callRunners(context, applicationArguments);
} }
catch (Throwable ex) { catch (Throwable ex) {

@ -56,9 +56,9 @@ class StartupInfoLogger {
applicationLog.debug(LogMessage.of(this::getRunningMessage)); applicationLog.debug(LogMessage.of(this::getRunningMessage));
} }
void logStarted(Log applicationLog, Duration timeTakeToStartup) { void logStarted(Log applicationLog, Duration timeTakenToStartup) {
if (applicationLog.isInfoEnabled()) { if (applicationLog.isInfoEnabled()) {
applicationLog.info(getStartedMessage(timeTakeToStartup)); applicationLog.info(getStartedMessage(timeTakenToStartup));
} }
} }
@ -83,12 +83,12 @@ class StartupInfoLogger {
return message; return message;
} }
private CharSequence getStartedMessage(Duration timeTakeToStartup) { private CharSequence getStartedMessage(Duration timeTakenToStartup) {
StringBuilder message = new StringBuilder(); StringBuilder message = new StringBuilder();
message.append("Started "); message.append("Started ");
appendApplicationName(message); appendApplicationName(message);
message.append(" in "); message.append(" in ");
message.append(timeTakeToStartup.toMillis() / 1000.0); message.append(timeTakenToStartup.toMillis() / 1000.0);
message.append(" seconds"); message.append(" seconds");
try { try {
double uptime = ManagementFactory.getRuntimeMXBean().getUptime() / 1000.0; double uptime = ManagementFactory.getRuntimeMXBean().getUptime() / 1000.0;

@ -604,7 +604,7 @@ public class SpringApplicationBuilder {
/** /**
* Whether to allow circular references between beans and automatically try to resolve * Whether to allow circular references between beans and automatically try to resolve
* them. * them.
* @param allowCircularReferences whether circular references are allows * @param allowCircularReferences whether circular references are allowed
* @return the current builder * @return the current builder
* @since 2.6.0 * @since 2.6.0
* @see AbstractAutowireCapableBeanFactory#setAllowCircularReferences(boolean) * @see AbstractAutowireCapableBeanFactory#setAllowCircularReferences(boolean)

@ -56,8 +56,8 @@ class StartupInfoLoggerTests {
@Test @Test
void startedFormat() { void startedFormat() {
given(this.log.isInfoEnabled()).willReturn(true); given(this.log.isInfoEnabled()).willReturn(true);
Duration timeTakeToStartup = Duration.ofMillis(10); Duration timeTakenToStartup = Duration.ofMillis(10);
new StartupInfoLogger(getClass()).logStarted(this.log, timeTakeToStartup); new StartupInfoLogger(getClass()).logStarted(this.log, timeTakenToStartup);
ArgumentCaptor<Object> captor = ArgumentCaptor.forClass(Object.class); ArgumentCaptor<Object> captor = ArgumentCaptor.forClass(Object.class);
verify(this.log).info(captor.capture()); verify(this.log).info(captor.capture());
assertThat(captor.getValue().toString()).matches("Started " + getClass().getSimpleName() assertThat(captor.getValue().toString()).matches("Started " + getClass().getSimpleName()

Loading…
Cancel
Save