Skip to content
Closed

Polish #7081

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public static ConditionMessage empty() {
/**
* Factory method to create a new {@link ConditionMessage} with a specific message.
* @param message the source message (may be a format string if {@code args} are
* specified
* specified)
* @param args format arguments for the message
* @return a new {@link ConditionMessage} instance
*/
Expand All @@ -155,7 +155,7 @@ public static ConditionMessage of(String message, Object... args) {
/**
* Factory method to create a new {@link ConditionMessage} comprised of the specified
* messages.
* @param messages the source messages (may be {@code null}
* @param messages the source messages (may be {@code null})
* @return a new {@link ConditionMessage} instance
*/
public static ConditionMessage of(Collection<? extends ConditionMessage> messages) {
Expand Down Expand Up @@ -283,7 +283,7 @@ public ConditionMessage available(String item) {

/**
* Indicates something is not available. For example {@code notAvailable("time")}
* results in the message "time in not available".
* results in the message "time is not available".
* @param item the item that is not available
* @return a built {@link ConditionMessage}
*/
Expand Down Expand Up @@ -374,9 +374,9 @@ public ConditionMessage items(Collection<?> items) {
}

/**
* Indicate the items. For example
* {@code didNotFind("bean", "beans").items(Collections.singleton("x")} results in
* the message "did not find bean x".
* Indicate the items with a {@link Style}. For example
* {@code didNotFind("bean", "beans").items(Style.QUOTE, Collections.singleton("x")} results in
* the message "did not find bean 'x'".
* @param style the render style
* @param items the source of the items (may be {@code null})
* @return a built {@link ConditionMessage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void foundExactlyShouldConstructMessage() throws Exception {
}

@Test
public void foundWhenSingleElementShouldUsingSingular() throws Exception {
public void foundWhenSingleElementShouldUseSingular() throws Exception {
ConditionMessage message = ConditionMessage.forCondition(Test.class)
.found("bean", "beans").items("a");
assertThat(message.toString()).isEqualTo("@Test found bean a");
Expand Down Expand Up @@ -160,7 +160,7 @@ public void foundWhenQuoteStyleShouldQuote() throws Exception {
}

@Test
public void didNotFindWhenSingleElementShouldUsingSingular() throws Exception {
public void didNotFindWhenSingleElementShouldUseSingular() throws Exception {
ConditionMessage message = ConditionMessage.forCondition(Test.class)
.didNotFind("class", "classes").items("a");
assertThat(message.toString()).isEqualTo("@Test did not find class a");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
* {@link Condition} that checks that a {@link Restarter} is available an initialized.
* {@link Condition} that checks that a {@link Restarter} is available and initialized.
*
* @author Phillip Webb
* @see ConditionalOnInitializedRestarter
Expand All @@ -35,7 +35,7 @@ class OnInitializedRestarterCondition extends SpringBootCondition {
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
ConditionMessage.Builder message = ConditionMessage
.forCondition("Initializer Restarter Condition");
.forCondition("Initialized Restarter Condition");
Restarter restarter = getRestarter();
if (restarter == null) {
return ConditionOutcome.noMatch(message.because("unavailable"));
Expand Down
8 changes: 4 additions & 4 deletions spring-boot-docs/src/main/asciidoc/howto.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ can send us a {github-code}[pull request].

[[howto-failure-analyzer]]
=== Create your own FailureAnalyzer
{dc-spring-boot}/diagnostics/FailureAnalyzer.{dc-ext}[[`FailureAnalyzer`] is a great way
{dc-spring-boot}/diagnostics/FailureAnalyzer.{dc-ext}[`FailureAnalyzer`] is a great way
to intercept an exception on startup and turn it into a human-readable message, wrapped
into a {dc-spring-boot}/diagnostics/FailureAnalysis.{dc-ext}[[`FailureAnalysis`]. Spring
into a {dc-spring-boot}/diagnostics/FailureAnalysis.{dc-ext}[`FailureAnalysis`]. Spring
Boot provides such analyzer for application context related exceptions, JSR-303
validations and more. It is actually very easy to create your own.

`AbstractFailureAnalyzer` is a convenient extension of `FailureAnalyzer` that checks the
presence of a specified exception type in the exception to handle. You can extend from
that so that your implementation gets a chance to handle the exception only when it is
actually present. If for whatever reason you can't handle the exception, return `null`
to let another implementation a chance to handle the exception.
to give another implementation a chance to handle the exception.

`FailureAnalyzer` implementations are to be registered in a `META-INF/spring.factories`:
the following registers `ProjectConstraintViolationFailureAnalyzer`:
Expand Down Expand Up @@ -2614,7 +2614,7 @@ then be depended upon by your application and other projects.
If you cannot rearrange your code as recommended above, Spring Boot's Maven and Gradle
plugins must be configured to produce a separate artifact that is suitable for use as a
dependency. The executable archive cannot be used as a dependency as the
<<appendix-executable-jar-format.adoc#executable-jar-jar-file-structure,exectuable jar
<<appendix-executable-jar-format.adoc#executable-jar-jar-file-structure,executable jar
format>> packages application classes in `BOOT-INF/classes`. This means
that they cannot be found when the executable jar is used as a dependency.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5193,7 +5193,7 @@ Data JPA tests may also inject a
bean which provides an alternative to the standard JPA `EntityManager` specifically
designed for tests. If you want to use `TestEntityManager` outside of `@DataJpaTests` you
can also use the `@AutoConfigureTestEntityManager` annotation. A `JdbcTemplate` is also
available should you need that.
available if you need that.

[source,java,indent=0]
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.test.context.BootstrapWith;
import org.springframework.test.context.junit4.SpringRunner;

Expand Down Expand Up @@ -83,9 +82,4 @@ static class ExampleBean {

}

@Component
static class ExampleTestComponent {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ public void parseSpyBeanOnClassAndField() throws Exception {
QualifierDefinition qualifier = QualifierDefinition.forElement(
ReflectionUtils.findField(SpyBeanOnClassAndField.class, "caller"));
assertThat(fieldDefinition.getQualifier()).isNotNull().isEqualTo(qualifier);
assertThat(fieldDefinition.getTypeToSpy().resolve())
.isEqualTo(ExampleServiceCaller.class);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
/**
* Test {@link MockBean} on a test class field can be used to replace existing bean while
* preserving qualifiers.
*
* @author Stephane Nicoll
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
public class MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@

import org.springframework.beans.factory.annotation.Qualifier;

/**
* Custom qualifier for testing.
*
* @author Stephane Nicoll
*/
@Qualifier
@Retention(RetentionPolicy.RUNTIME)
public @interface CustomQualifier {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected abstract T deserializeObject(JsonParser jsonParser,
/**
* Helper method to extract a value from the given {@code jsonNode} or return
* {@code null} when the node itself is {@code null}.
* @param jsonNode the source node (may be {@code null}
* @param jsonNode the source node (may be {@code null})
* @param type the data type. May be {@link String}, {@link Boolean}, {@link Long},
* {@link Integer}, {@link Short}, {@link Double}, {@link Float}, {@link BigDecimal}
* or {@link BigInteger}.
Expand Down