Skip to content

Commit 3ca6ed6

Browse files
committed
Polish
Closes gh-26190
2 parents 6c68f36 + b1170ef commit 3ca6ed6

File tree

6 files changed

+21
-13
lines changed

6 files changed

+21
-13
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6948,7 +6948,7 @@ You can use the `@DataJpaTest` annotation to test JPA applications.
69486948
By default, it scans for `@Entity` classes and configures Spring Data JPA repositories.
69496949
If an embedded database is available on the classpath, it configures one as well.
69506950
SQL queries are logged by default by setting the `spring.jpa.show-sql` property to `true`.
6951-
This can be disabled using the `showSql()` attribute of the annotation.
6951+
This can be disabled by using the `showSql()` attribute of the annotation.
69526952

69536953
Regular `@Component` and `@ConfigurationProperties` beans are not scanned when the `@DataJpaTest` annotation is used.
69546954
`@EnableConfigurationProperties` can be used to include `@ConfigurationProperties` beans.

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
* override these settings.
5555
* <p>
5656
* SQL queries are logged by default by setting the {@code spring.jpa.show-sql} property
57-
* to {@code true}. This can be disabled using the {@link DataJpaTest#showSql() showSql}
58-
* attribute.
57+
* to {@code true}. This can be disabled by using the {@link DataJpaTest#showSql()
58+
* showSql} attribute.
5959
* <p>
6060
* If you are looking to load your full application configuration, but use an embedded
6161
* database, you should consider {@link SpringBootTest @SpringBootTest} combined with

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/availability/ApplicationAvailabilityBean.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
public class ApplicationAvailabilityBean
3939
implements ApplicationAvailability, ApplicationListener<AvailabilityChangeEvent<?>> {
4040

41-
private static final Log logger = LogFactory.getLog(ApplicationAvailability.class);
41+
private static final Log logger = LogFactory.getLog(ApplicationAvailabilityBean.class);
4242

4343
private final Map<Class<? extends AvailabilityState>, AvailabilityChangeEvent<?>> events = new HashMap<>();
4444

@@ -70,6 +70,13 @@ public void onApplicationEvent(AvailabilityChangeEvent<?> event) {
7070
}
7171

7272
private void logStateChange(AvailabilityChangeEvent<?> event) {
73+
if (logger.isInfoEnabled()) {
74+
StringBuilder message = createStateChangeMessage(event);
75+
logger.info(message);
76+
}
77+
}
78+
79+
private StringBuilder createStateChangeMessage(AvailabilityChangeEvent<?> event) {
7380
Class<? extends AvailabilityState> stateType = getStateType(event.getState());
7481
StringBuilder message = new StringBuilder(
7582
"Application availability state " + stateType.getSimpleName() + " changed");
@@ -78,15 +85,16 @@ private void logStateChange(AvailabilityChangeEvent<?> event) {
7885
message.append(" from " + lastChangeEvent.getState());
7986
}
8087
message.append(" to " + event.getState());
81-
if (event.getSource() != null) {
82-
if (event.getSource() instanceof Throwable) {
83-
message.append(": " + event.getSource());
88+
Object source = event.getSource();
89+
if (source != null) {
90+
if (source instanceof Throwable) {
91+
message.append(": " + source);
8492
}
85-
else if (!(event.getSource() instanceof ApplicationEventPublisher)) {
86-
message.append(": " + event.getSource().getClass().getName());
93+
else if (!(source instanceof ApplicationEventPublisher)) {
94+
message.append(": " + source.getClass().getName());
8795
}
8896
}
89-
logger.info(message);
97+
return message;
9098
}
9199

92100
@SuppressWarnings("unchecked")

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/ApplicationConversionService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class ApplicationConversionService extends FormattingConversionService {
5555

5656
private static volatile ApplicationConversionService sharedInstance;
5757

58-
private boolean unmodifiable;
58+
private final boolean unmodifiable;
5959

6060
public ApplicationConversionService() {
6161
this(null);

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/jetty/Jetty10ReactiveWebServerFactoryTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import static org.assertj.core.api.Assertions.assertThat;
2424

2525
/**
26-
* Tests for {@JettyReactiveWebServerFactory} with Jetty 10.
26+
* Tests for {@link JettyReactiveWebServerFactory} with Jetty 10.
2727
*
2828
* @author Andy Wilkinson
2929
*/

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/jetty/Jetty10ServletWebServerFactoryTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import static org.assertj.core.api.Assertions.assertThat;
2424

2525
/**
26-
* Tests for {@JettyServletWebServerFactory} with Jetty 10.
26+
* Tests for {@link JettyServletWebServerFactory} with Jetty 10.
2727
*
2828
* @author Andy Wilkinson
2929
*/

0 commit comments

Comments
 (0)