Merge branch '2.0.x'

This commit is contained in:
Stephane Nicoll 2018-06-01 09:26:29 +02:00
commit bc47bf44a9
9 changed files with 42 additions and 47 deletions

View File

@ -224,7 +224,7 @@ This module contains core items and annotations that can be helpful when testing
=== spring-boot-test-autoconfigure
Like other Spring Boot Auto-Configuration modules, spring-boot-test-autoconfigure, provides auto-configuration
Like other Spring Boot auto-configuration modules, spring-boot-test-autoconfigure, provides auto-configuration
for tests based on the classpath. It includes a number of annotations that can be used to automatically
configure a slice of your application that needs to be tested.

View File

@ -39,7 +39,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.util.Assert;
/**
* {@link EnableAutoConfiguration Auto-Configuration} for Jest.
* {@link EnableAutoConfiguration Auto-configuration} for Jest.
*
* @author Stephane Nicoll
* @since 1.4.0

View File

@ -134,7 +134,9 @@ public class Restarter {
Assert.notNull(thread, "Thread must not be null");
Assert.notNull(args, "Args must not be null");
Assert.notNull(initializer, "Initializer must not be null");
this.logger.debug("Creating new Restarter for thread " + thread);
if (this.logger.isDebugEnabled()) {
this.logger.debug("Creating new Restarter for thread " + thread);
}
SilentExitExceptionHandler.setup(thread);
this.forceReferenceCleanup = forceReferenceCleanup;
this.initialUrls = initializer.getInitialUrls(thread);
@ -360,7 +362,10 @@ public class Restarter {
clear(Class.forName(className), fieldName);
}
catch (Exception ex) {
this.logger.debug("Unable to clear field " + className + " " + fieldName, ex);
if (this.logger.isDebugEnabled()) {
this.logger.debug("Unable to clear field " + className + " " + fieldName,
ex);
}
}
}
@ -377,15 +382,15 @@ public class Restarter {
}
}
catch (Exception ex) {
this.logger.debug("Unable to clear field " + type + " " + fieldName, ex);
if (this.logger.isDebugEnabled()) {
this.logger.debug("Unable to clear field " + type + " " + fieldName, ex);
}
}
}
private boolean isFromRestartClassLoader(Object object) {
if (object instanceof Class) {
return ((Class<?>) object).getClassLoader() instanceof RestartClassLoader;
}
return false;
return (object instanceof Class
&& ((Class<?>) object).getClassLoader() instanceof RestartClassLoader);
}
/**

View File

@ -3,7 +3,7 @@
[[common-application-properties]]
== Common application properties
Various properties can be specified inside your `application.properties` file, inside
your `application.yml` file, or as command line switches. This appendix provides a list
your `application.yml` file, or as command line switches. This appendix provides a list
of common Spring Boot properties and references to the underlying classes that consume
them.

View File

@ -662,7 +662,7 @@ that you have added. Since `spring-boot-starter-web` added Tomcat and Spring MVC
auto-configuration assumes that you are developing a web application and sets up Spring
accordingly.
.Starters and Auto-Configuration
.Starters and Auto-configuration
****
Auto-configuration is designed to work well with "`Starters`", but the two concepts are
not directly tied. You are free to pick and choose jar dependencies outside of the

View File

@ -2064,7 +2064,7 @@ directory locations). The root Servlet context path, `"/"`, is automatically add
location as well.
In addition to the "`standard`" static resource locations mentioned earlier, a special
case is made for http://www.webjars.org/[Webjars content]. Any resources with a path in
case is made for https://www.webjars.org/[Webjars content]. Any resources with a path in
`+/webjars/**+` are served from jar files if they are packaged in the Webjars format.
TIP: Do not use the `src/main/webapp` directory if your application is packaged as a jar.
@ -2625,7 +2625,7 @@ custom locations. So, if there is an `index.html` in any of your locations on st
is the home page of the application.
In addition to the "`standard`" static resource locations listed earlier, a special case
is made for http://www.webjars.org/[Webjars content]. Any resources with a path in
is made for https://www.webjars.org/[Webjars content]. Any resources with a path in
`+/webjars/**+` are served from jar files if they are packaged in the Webjars format.
TIP: Spring WebFlux applications do not strictly depend on the Servlet API, so they
@ -7259,7 +7259,7 @@ which auto-configures one for you.
[[boot-features-environment-test-utilities]]
[[boot-features-test-property-values]]
==== TestPropertyValues
`TestPropertyValues` lets you quickly add properties to a
`ConfigurableEnvironment` or `ConfigurableApplicationContext`. You can call it with

View File

@ -99,11 +99,11 @@ final class StringSequence implements CharSequence {
return startsWith(prefix, 0);
}
public boolean startsWith(CharSequence prefix, int toffset) {
if (length() - prefix.length() - toffset < 0) {
public boolean startsWith(CharSequence prefix, int offset) {
if (length() - prefix.length() - offset < 0) {
return false;
}
return subSequence(toffset, toffset + prefix.length()).equals(prefix);
return subSequence(offset, offset + prefix.length()).equals(prefix);
}
@Override

View File

@ -20,6 +20,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
@ -301,7 +302,7 @@ public class ConfigFileApplicationListener
private final List<PropertySourceLoader> propertySourceLoaders;
private LinkedList<Profile> profiles;
private Deque<Profile> profiles;
private List<Profile> processedProfiles;
@ -345,9 +346,9 @@ public class ConfigFileApplicationListener
// The default profile for these purposes is represented as null. We add it
// first so that it is processed first and has lowest priority.
this.profiles.add(null);
Set<Profile> activatedViaProperty = getProfilesActivatedViaActiveProfileProperty();
Set<Profile> activatedViaProperty = getProfilesActivatedViaProperty();
processOtherActiveProfiles(activatedViaProperty);
// Any pre-existing active activeProfiles set via property sources (e.g.
// Any pre-existing active profiles set via property sources (e.g.
// System
// properties) take precedence over those added in config files.
addActiveProfiles(activatedViaProperty);
@ -360,7 +361,7 @@ public class ConfigFileApplicationListener
}
}
private Set<Profile> getProfilesActivatedViaActiveProfileProperty() {
private Set<Profile> getProfilesActivatedViaProperty() {
if (!this.environment.containsProperty(ACTIVE_PROFILES_PROPERTY)
&& !this.environment.containsProperty(INCLUDE_PROFILES_PROPERTY)) {
return Collections.emptySet();
@ -385,8 +386,10 @@ public class ConfigFileApplicationListener
return;
}
addProfiles(profiles);
this.logger.debug("Activated activeProfiles "
+ StringUtils.collectionToCommaDelimitedString(profiles));
if (this.logger.isDebugEnabled()) {
this.logger.debug("Activated activeProfiles "
+ StringUtils.collectionToCommaDelimitedString(profiles));
}
this.activatedProfiles = true;
removeUnprocessedDefaultProfiles();
}

View File

@ -58,62 +58,49 @@ public class SampleTomcatDeployApplicationIT {
@Test
public void errorFromExceptionForRequestAcceptingAnythingProducesAJsonResponse()
throws Exception {
assertThatErrorFromExceptionProducesExpectedResponse(MediaType.ALL,
assertThatPathProducesExpectedResponse("/bootapp/exception", MediaType.ALL,
MediaType.APPLICATION_JSON);
}
@Test
public void errorFromExceptionForRequestAcceptingJsonProducesAJsonResponse()
throws Exception {
assertThatErrorFromExceptionProducesExpectedResponse(MediaType.APPLICATION_JSON,
MediaType.APPLICATION_JSON);
assertThatPathProducesExpectedResponse("/bootapp/exception",
MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON);
}
@Test
public void errorFromExceptionForRequestAcceptingHtmlProducesAnHtmlResponse()
throws Exception {
assertThatErrorFromExceptionProducesExpectedResponse(MediaType.TEXT_HTML,
assertThatPathProducesExpectedResponse("/bootapp/exception", MediaType.TEXT_HTML,
MediaType.TEXT_HTML);
}
@Test
public void sendErrorForRequestAcceptingAnythingProducesAJsonResponse()
throws Exception {
assertThatSendErrorProducesExpectedResponse(MediaType.ALL,
assertThatPathProducesExpectedResponse("/bootapp/send-error", MediaType.ALL,
MediaType.APPLICATION_JSON);
}
@Test
public void sendErrorForRequestAcceptingJsonProducesAJsonResponse() throws Exception {
assertThatSendErrorProducesExpectedResponse(MediaType.APPLICATION_JSON,
MediaType.APPLICATION_JSON);
assertThatPathProducesExpectedResponse("/bootapp/send-error",
MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON);
}
@Test
public void sendErrorForRequestAcceptingHtmlProducesAnHtmlResponse()
throws Exception {
assertThatSendErrorProducesExpectedResponse(MediaType.TEXT_HTML,
assertThatPathProducesExpectedResponse("/bootapp/send-error", MediaType.TEXT_HTML,
MediaType.TEXT_HTML);
}
private void assertThatSendErrorProducesExpectedResponse(MediaType accept,
private void assertThatPathProducesExpectedResponse(String path, MediaType accept,
MediaType contentType) {
RequestEntity<Void> request = RequestEntity
.get(URI.create("http://localhost:" + this.port + "/bootapp/send-error"))
.accept(accept).build();
ResponseEntity<String> response = this.rest.exchange(request, String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
assertThat(contentType.isCompatibleWith(response.getHeaders().getContentType()))
.as("%s is compatible with %s", contentType,
response.getHeaders().getContentType())
.isTrue();
}
private void assertThatErrorFromExceptionProducesExpectedResponse(MediaType accept,
MediaType contentType) {
RequestEntity<Void> request = RequestEntity
.get(URI.create("http://localhost:" + this.port + "/bootapp/exception"))
.accept(accept).build();
.get(URI.create("http://localhost:" + this.port + path)).accept(accept)
.build();
ResponseEntity<String> response = this.rest.exchange(request, String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
assertThat(contentType.isCompatibleWith(response.getHeaders().getContentType()))