Browse Source

Polish

Closes gh-26190
pull/26227/head
Stephane Nicoll 5 years ago
parent
commit
3ca6ed6246
  1. 2
      spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc
  2. 4
      spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java
  3. 22
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/availability/ApplicationAvailabilityBean.java
  4. 2
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/ApplicationConversionService.java
  5. 2
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/jetty/Jetty10ReactiveWebServerFactoryTests.java
  6. 2
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/jetty/Jetty10ServletWebServerFactoryTests.java

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

@ -6948,7 +6948,7 @@ You can use the `@DataJpaTest` annotation to test JPA applications.
By default, it scans for `@Entity` classes and configures Spring Data JPA repositories. By default, it scans for `@Entity` classes and configures Spring Data JPA repositories.
If an embedded database is available on the classpath, it configures one as well. If an embedded database is available on the classpath, it configures one as well.
SQL queries are logged by default by setting the `spring.jpa.show-sql` property to `true`. SQL queries are logged by default by setting the `spring.jpa.show-sql` property to `true`.
This can be disabled using the `showSql()` attribute of the annotation. This can be disabled by using the `showSql()` attribute of the annotation.
Regular `@Component` and `@ConfigurationProperties` beans are not scanned when the `@DataJpaTest` annotation is used. Regular `@Component` and `@ConfigurationProperties` beans are not scanned when the `@DataJpaTest` annotation is used.
`@EnableConfigurationProperties` can be used to include `@ConfigurationProperties` beans. `@EnableConfigurationProperties` can be used to include `@ConfigurationProperties` beans.

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

@ -54,8 +54,8 @@ import org.springframework.transaction.annotation.Transactional;
* override these settings. * override these settings.
* <p> * <p>
* SQL queries are logged by default by setting the {@code spring.jpa.show-sql} property * SQL queries are logged by default by setting the {@code spring.jpa.show-sql} property
* to {@code true}. This can be disabled using the {@link DataJpaTest#showSql() showSql} * to {@code true}. This can be disabled by using the {@link DataJpaTest#showSql()
* attribute. * showSql} attribute.
* <p> * <p>
* If you are looking to load your full application configuration, but use an embedded * If you are looking to load your full application configuration, but use an embedded
* database, you should consider {@link SpringBootTest @SpringBootTest} combined with * database, you should consider {@link SpringBootTest @SpringBootTest} combined with

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

@ -38,7 +38,7 @@ import org.springframework.util.Assert;
public class ApplicationAvailabilityBean public class ApplicationAvailabilityBean
implements ApplicationAvailability, ApplicationListener<AvailabilityChangeEvent<?>> { implements ApplicationAvailability, ApplicationListener<AvailabilityChangeEvent<?>> {
private static final Log logger = LogFactory.getLog(ApplicationAvailability.class); private static final Log logger = LogFactory.getLog(ApplicationAvailabilityBean.class);
private final Map<Class<? extends AvailabilityState>, AvailabilityChangeEvent<?>> events = new HashMap<>(); private final Map<Class<? extends AvailabilityState>, AvailabilityChangeEvent<?>> events = new HashMap<>();
@ -70,6 +70,13 @@ public class ApplicationAvailabilityBean
} }
private void logStateChange(AvailabilityChangeEvent<?> event) { private void logStateChange(AvailabilityChangeEvent<?> event) {
if (logger.isInfoEnabled()) {
StringBuilder message = createStateChangeMessage(event);
logger.info(message);
}
}
private StringBuilder createStateChangeMessage(AvailabilityChangeEvent<?> event) {
Class<? extends AvailabilityState> stateType = getStateType(event.getState()); Class<? extends AvailabilityState> stateType = getStateType(event.getState());
StringBuilder message = new StringBuilder( StringBuilder message = new StringBuilder(
"Application availability state " + stateType.getSimpleName() + " changed"); "Application availability state " + stateType.getSimpleName() + " changed");
@ -78,15 +85,16 @@ public class ApplicationAvailabilityBean
message.append(" from " + lastChangeEvent.getState()); message.append(" from " + lastChangeEvent.getState());
} }
message.append(" to " + event.getState()); message.append(" to " + event.getState());
if (event.getSource() != null) { Object source = event.getSource();
if (event.getSource() instanceof Throwable) { if (source != null) {
message.append(": " + event.getSource()); if (source instanceof Throwable) {
message.append(": " + source);
} }
else if (!(event.getSource() instanceof ApplicationEventPublisher)) { else if (!(source instanceof ApplicationEventPublisher)) {
message.append(": " + event.getSource().getClass().getName()); message.append(": " + source.getClass().getName());
} }
} }
logger.info(message); return message;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

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

@ -55,7 +55,7 @@ public class ApplicationConversionService extends FormattingConversionService {
private static volatile ApplicationConversionService sharedInstance; private static volatile ApplicationConversionService sharedInstance;
private boolean unmodifiable; private final boolean unmodifiable;
public ApplicationConversionService() { public ApplicationConversionService() {
this(null); this(null);

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

@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
/** /**
* Tests for {@JettyReactiveWebServerFactory} with Jetty 10. * Tests for {@link JettyReactiveWebServerFactory} with Jetty 10.
* *
* @author Andy Wilkinson * @author Andy Wilkinson
*/ */

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

@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
/** /**
* Tests for {@JettyServletWebServerFactory} with Jetty 10. * Tests for {@link JettyServletWebServerFactory} with Jetty 10.
* *
* @author Andy Wilkinson * @author Andy Wilkinson
*/ */

Loading…
Cancel
Save