Skip to content

Commit bc47bf4

Browse files
committed
Merge branch '2.0.x'
2 parents 81ef6fe + 152ce14 commit bc47bf4

File tree

9 files changed

+42
-47
lines changed

9 files changed

+42
-47
lines changed

README.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ This module contains core items and annotations that can be helpful when testing
224224

225225

226226
=== spring-boot-test-autoconfigure
227-
Like other Spring Boot Auto-Configuration modules, spring-boot-test-autoconfigure, provides auto-configuration
227+
Like other Spring Boot auto-configuration modules, spring-boot-test-autoconfigure, provides auto-configuration
228228
for tests based on the classpath. It includes a number of annotations that can be used to automatically
229229
configure a slice of your application that needs to be tested.
230230

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/jest/JestAutoConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import org.springframework.util.Assert;
4040

4141
/**
42-
* {@link EnableAutoConfiguration Auto-Configuration} for Jest.
42+
* {@link EnableAutoConfiguration Auto-configuration} for Jest.
4343
*
4444
* @author Stephane Nicoll
4545
* @since 1.4.0

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/Restarter.java

+12-7
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ protected Restarter(Thread thread, String[] args, boolean forceReferenceCleanup,
134134
Assert.notNull(thread, "Thread must not be null");
135135
Assert.notNull(args, "Args must not be null");
136136
Assert.notNull(initializer, "Initializer must not be null");
137-
this.logger.debug("Creating new Restarter for thread " + thread);
137+
if (this.logger.isDebugEnabled()) {
138+
this.logger.debug("Creating new Restarter for thread " + thread);
139+
}
138140
SilentExitExceptionHandler.setup(thread);
139141
this.forceReferenceCleanup = forceReferenceCleanup;
140142
this.initialUrls = initializer.getInitialUrls(thread);
@@ -360,7 +362,10 @@ private void clear(String className, String fieldName) {
360362
clear(Class.forName(className), fieldName);
361363
}
362364
catch (Exception ex) {
363-
this.logger.debug("Unable to clear field " + className + " " + fieldName, ex);
365+
if (this.logger.isDebugEnabled()) {
366+
this.logger.debug("Unable to clear field " + className + " " + fieldName,
367+
ex);
368+
}
364369
}
365370
}
366371

@@ -377,15 +382,15 @@ private void clear(Class<?> type, String fieldName) throws Exception {
377382
}
378383
}
379384
catch (Exception ex) {
380-
this.logger.debug("Unable to clear field " + type + " " + fieldName, ex);
385+
if (this.logger.isDebugEnabled()) {
386+
this.logger.debug("Unable to clear field " + type + " " + fieldName, ex);
387+
}
381388
}
382389
}
383390

384391
private boolean isFromRestartClassLoader(Object object) {
385-
if (object instanceof Class) {
386-
return ((Class<?>) object).getClassLoader() instanceof RestartClassLoader;
387-
}
388-
return false;
392+
return (object instanceof Class
393+
&& ((Class<?>) object).getClassLoader() instanceof RestartClassLoader);
389394
}
390395

391396
/**

spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc

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

spring-boot-project/spring-boot-docs/src/main/asciidoc/getting-started.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ that you have added. Since `spring-boot-starter-web` added Tomcat and Spring MVC
662662
auto-configuration assumes that you are developing a web application and sets up Spring
663663
accordingly.
664664

665-
.Starters and Auto-Configuration
665+
.Starters and Auto-configuration
666666
****
667667
Auto-configuration is designed to work well with "`Starters`", but the two concepts are
668668
not directly tied. You are free to pick and choose jar dependencies outside of the

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -2064,7 +2064,7 @@ directory locations). The root Servlet context path, `"/"`, is automatically add
20642064
location as well.
20652065

20662066
In addition to the "`standard`" static resource locations mentioned earlier, a special
2067-
case is made for http://www.webjars.org/[Webjars content]. Any resources with a path in
2067+
case is made for https://www.webjars.org/[Webjars content]. Any resources with a path in
20682068
`+/webjars/**+` are served from jar files if they are packaged in the Webjars format.
20692069

20702070
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
26252625
is the home page of the application.
26262626

26272627
In addition to the "`standard`" static resource locations listed earlier, a special case
2628-
is made for http://www.webjars.org/[Webjars content]. Any resources with a path in
2628+
is made for https://www.webjars.org/[Webjars content]. Any resources with a path in
26292629
`+/webjars/**+` are served from jar files if they are packaged in the Webjars format.
26302630

26312631
TIP: Spring WebFlux applications do not strictly depend on the Servlet API, so they
@@ -7259,7 +7259,7 @@ which auto-configures one for you.
72597259

72607260

72617261

7262-
[[boot-features-environment-test-utilities]]
7262+
[[boot-features-test-property-values]]
72637263
==== TestPropertyValues
72647264
`TestPropertyValues` lets you quickly add properties to a
72657265
`ConfigurableEnvironment` or `ConfigurableApplicationContext`. You can call it with

spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/StringSequence.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ public boolean startsWith(CharSequence prefix) {
9999
return startsWith(prefix, 0);
100100
}
101101

102-
public boolean startsWith(CharSequence prefix, int toffset) {
103-
if (length() - prefix.length() - toffset < 0) {
102+
public boolean startsWith(CharSequence prefix, int offset) {
103+
if (length() - prefix.length() - offset < 0) {
104104
return false;
105105
}
106-
return subSequence(toffset, toffset + prefix.length()).equals(prefix);
106+
return subSequence(offset, offset + prefix.length()).equals(prefix);
107107
}
108108

109109
@Override

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java

+9-6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.ArrayList;
2121
import java.util.Arrays;
2222
import java.util.Collections;
23+
import java.util.Deque;
2324
import java.util.HashMap;
2425
import java.util.LinkedHashMap;
2526
import java.util.LinkedHashSet;
@@ -301,7 +302,7 @@ private class Loader {
301302

302303
private final List<PropertySourceLoader> propertySourceLoaders;
303304

304-
private LinkedList<Profile> profiles;
305+
private Deque<Profile> profiles;
305306

306307
private List<Profile> processedProfiles;
307308

@@ -345,9 +346,9 @@ private void initializeProfiles() {
345346
// The default profile for these purposes is represented as null. We add it
346347
// first so that it is processed first and has lowest priority.
347348
this.profiles.add(null);
348-
Set<Profile> activatedViaProperty = getProfilesActivatedViaActiveProfileProperty();
349+
Set<Profile> activatedViaProperty = getProfilesActivatedViaProperty();
349350
processOtherActiveProfiles(activatedViaProperty);
350-
// Any pre-existing active activeProfiles set via property sources (e.g.
351+
// Any pre-existing active profiles set via property sources (e.g.
351352
// System
352353
// properties) take precedence over those added in config files.
353354
addActiveProfiles(activatedViaProperty);
@@ -360,7 +361,7 @@ private void initializeProfiles() {
360361
}
361362
}
362363

363-
private Set<Profile> getProfilesActivatedViaActiveProfileProperty() {
364+
private Set<Profile> getProfilesActivatedViaProperty() {
364365
if (!this.environment.containsProperty(ACTIVE_PROFILES_PROPERTY)
365366
&& !this.environment.containsProperty(INCLUDE_PROFILES_PROPERTY)) {
366367
return Collections.emptySet();
@@ -385,8 +386,10 @@ void addActiveProfiles(Set<Profile> profiles) {
385386
return;
386387
}
387388
addProfiles(profiles);
388-
this.logger.debug("Activated activeProfiles "
389-
+ StringUtils.collectionToCommaDelimitedString(profiles));
389+
if (this.logger.isDebugEnabled()) {
390+
this.logger.debug("Activated activeProfiles "
391+
+ StringUtils.collectionToCommaDelimitedString(profiles));
392+
}
390393
this.activatedProfiles = true;
391394
removeUnprocessedDefaultProfiles();
392395
}

spring-boot-tests/spring-boot-deployment-tests/spring-boot-deployment-test-tomcat/src/test/java/sample/SampleTomcatDeployApplicationIT.java

+11-24
Original file line numberDiff line numberDiff line change
@@ -58,62 +58,49 @@ public void testHealth() throws Exception {
5858
@Test
5959
public void errorFromExceptionForRequestAcceptingAnythingProducesAJsonResponse()
6060
throws Exception {
61-
assertThatErrorFromExceptionProducesExpectedResponse(MediaType.ALL,
61+
assertThatPathProducesExpectedResponse("/bootapp/exception", MediaType.ALL,
6262
MediaType.APPLICATION_JSON);
6363
}
6464

6565
@Test
6666
public void errorFromExceptionForRequestAcceptingJsonProducesAJsonResponse()
6767
throws Exception {
68-
assertThatErrorFromExceptionProducesExpectedResponse(MediaType.APPLICATION_JSON,
69-
MediaType.APPLICATION_JSON);
68+
assertThatPathProducesExpectedResponse("/bootapp/exception",
69+
MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON);
7070
}
7171

7272
@Test
7373
public void errorFromExceptionForRequestAcceptingHtmlProducesAnHtmlResponse()
7474
throws Exception {
75-
assertThatErrorFromExceptionProducesExpectedResponse(MediaType.TEXT_HTML,
75+
assertThatPathProducesExpectedResponse("/bootapp/exception", MediaType.TEXT_HTML,
7676
MediaType.TEXT_HTML);
7777
}
7878

7979
@Test
8080
public void sendErrorForRequestAcceptingAnythingProducesAJsonResponse()
8181
throws Exception {
82-
assertThatSendErrorProducesExpectedResponse(MediaType.ALL,
82+
assertThatPathProducesExpectedResponse("/bootapp/send-error", MediaType.ALL,
8383
MediaType.APPLICATION_JSON);
8484
}
8585

8686
@Test
8787
public void sendErrorForRequestAcceptingJsonProducesAJsonResponse() throws Exception {
88-
assertThatSendErrorProducesExpectedResponse(MediaType.APPLICATION_JSON,
89-
MediaType.APPLICATION_JSON);
88+
assertThatPathProducesExpectedResponse("/bootapp/send-error",
89+
MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON);
9090
}
9191

9292
@Test
9393
public void sendErrorForRequestAcceptingHtmlProducesAnHtmlResponse()
9494
throws Exception {
95-
assertThatSendErrorProducesExpectedResponse(MediaType.TEXT_HTML,
95+
assertThatPathProducesExpectedResponse("/bootapp/send-error", MediaType.TEXT_HTML,
9696
MediaType.TEXT_HTML);
9797
}
9898

99-
private void assertThatSendErrorProducesExpectedResponse(MediaType accept,
100-
MediaType contentType) {
101-
RequestEntity<Void> request = RequestEntity
102-
.get(URI.create("http://localhost:" + this.port + "/bootapp/send-error"))
103-
.accept(accept).build();
104-
ResponseEntity<String> response = this.rest.exchange(request, String.class);
105-
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
106-
assertThat(contentType.isCompatibleWith(response.getHeaders().getContentType()))
107-
.as("%s is compatible with %s", contentType,
108-
response.getHeaders().getContentType())
109-
.isTrue();
110-
}
111-
112-
private void assertThatErrorFromExceptionProducesExpectedResponse(MediaType accept,
99+
private void assertThatPathProducesExpectedResponse(String path, MediaType accept,
113100
MediaType contentType) {
114101
RequestEntity<Void> request = RequestEntity
115-
.get(URI.create("http://localhost:" + this.port + "/bootapp/exception"))
116-
.accept(accept).build();
102+
.get(URI.create("http://localhost:" + this.port + path)).accept(accept)
103+
.build();
117104
ResponseEntity<String> response = this.rest.exchange(request, String.class);
118105
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
119106
assertThat(contentType.isCompatibleWith(response.getHeaders().getContentType()))

0 commit comments

Comments
 (0)