Skip to content

Commit 620208a

Browse files
committed
Polish
1 parent f80db03 commit 620208a

File tree

5 files changed

+25
-33
lines changed

5 files changed

+25
-33
lines changed

Diff for: spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorProperties.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ public enum IncludeStacktrace {
103103
public static class Whitelabel {
104104

105105
/**
106-
* Whether to enable the default error page displayed in browsers in case of a server error.
106+
* Whether to enable the default error page displayed in browsers in case of a
107+
* server error.
107108
*/
108109
private boolean enabled = true;
109110

@@ -114,6 +115,7 @@ public boolean isEnabled() {
114115
public void setEnabled(boolean enabled) {
115116
this.enabled = enabled;
116117
}
118+
117119
}
118120

119121
}

Diff for: spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,20 @@ protected Mono<ServerResponse> renderErrorView(ServerRequest request) {
119119
boolean includeStackTrace = isIncludeStackTrace(request, MediaType.TEXT_HTML);
120120
Map<String, Object> error = getErrorAttributes(request, includeStackTrace);
121121
HttpStatus errorStatus = getHttpStatus(error);
122-
ServerResponse.BodyBuilder response = ServerResponse.status(errorStatus)
122+
ServerResponse.BodyBuilder responseBody = ServerResponse.status(errorStatus)
123123
.contentType(MediaType.TEXT_HTML);
124124
Flux<ServerResponse> result = Flux
125125
.just("error/" + errorStatus.toString(),
126126
"error/" + SERIES_VIEWS.get(errorStatus.series()), "error/error")
127-
.flatMap((viewName) -> renderErrorView(viewName, response, error));
127+
.flatMap((viewName) -> renderErrorView(viewName, responseBody, error));
128128
if (this.errorProperties.getWhitelabel().isEnabled()) {
129-
result = result.switchIfEmpty(renderDefaultErrorView(response, error));
129+
result = result.switchIfEmpty(renderDefaultErrorView(responseBody, error));
130130
}
131131
else {
132132
Throwable ex = getError(request);
133133
result = result.switchIfEmpty(Mono.error(ex));
134134
}
135-
return result.next().doOnNext((resp) -> logError(request, errorStatus));
135+
return result.next().doOnNext((response) -> logError(request, errorStatus));
136136
}
137137

138138
/**

Diff for: spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfigurationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class CouchbaseAutoConfigurationTests {
5353

5454
@Test
5555
public void bootstrapHostsIsRequired() {
56-
this.contextRunner.run((context) -> assertNoCouchbaseBeans(context));
56+
this.contextRunner.run(this::assertNoCouchbaseBeans);
5757
}
5858

5959
@Test

Diff for: spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.java

+16-26
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,8 @@ public void notFound() {
9595
this.contextRunner.run((context) -> {
9696
WebTestClient client = WebTestClient.bindToApplicationContext(context)
9797
.build();
98-
client.get().uri("/notFound").exchange()
99-
.expectStatus().isNotFound()
100-
.expectBody().jsonPath("status")
101-
.isEqualTo("404").jsonPath("error")
98+
client.get().uri("/notFound").exchange().expectStatus().isNotFound()
99+
.expectBody().jsonPath("status").isEqualTo("404").jsonPath("error")
102100
.isEqualTo(HttpStatus.NOT_FOUND.getReasonPhrase()).jsonPath("path")
103101
.isEqualTo(("/notFound")).jsonPath("exception").doesNotExist();
104102
});
@@ -125,10 +123,8 @@ public void bindingResultError() {
125123
WebTestClient client = WebTestClient.bindToApplicationContext(context)
126124
.build();
127125
client.post().uri("/bind").contentType(MediaType.APPLICATION_JSON)
128-
.syncBody("{}").exchange()
129-
.expectStatus().isBadRequest()
130-
.expectBody().jsonPath("status")
131-
.isEqualTo("400").jsonPath("error")
126+
.syncBody("{}").exchange().expectStatus().isBadRequest().expectBody()
127+
.jsonPath("status").isEqualTo("400").jsonPath("error")
132128
.isEqualTo(HttpStatus.BAD_REQUEST.getReasonPhrase()).jsonPath("path")
133129
.isEqualTo(("/bind")).jsonPath("exception").doesNotExist()
134130
.jsonPath("errors").isArray().jsonPath("message").isNotEmpty();
@@ -195,10 +191,9 @@ public void statusException() {
195191
.run((context) -> {
196192
WebTestClient client = WebTestClient.bindToApplicationContext(context)
197193
.build();
198-
client.get().uri("/badRequest").exchange()
199-
.expectStatus().isBadRequest()
200-
.expectBody().jsonPath("status").isEqualTo("400")
201-
.jsonPath("error")
194+
client.get().uri("/badRequest").exchange().expectStatus()
195+
.isBadRequest().expectBody().jsonPath("status")
196+
.isEqualTo("400").jsonPath("error")
202197
.isEqualTo(HttpStatus.BAD_REQUEST.getReasonPhrase())
203198
.jsonPath("exception")
204199
.isEqualTo(ResponseStatusException.class.getName());
@@ -254,9 +249,8 @@ public void testExceptionWithNullMessage() {
254249
WebTestClient client = WebTestClient.bindToApplicationContext(context)
255250
.build();
256251
String body = client.get().uri("/notfound")
257-
.accept(MediaType.TEXT_HTML).exchange()
258-
.expectStatus().isNotFound()
259-
.expectHeader().contentType(MediaType.TEXT_HTML)
252+
.accept(MediaType.TEXT_HTML).exchange().expectStatus()
253+
.isNotFound().expectHeader().contentType(MediaType.TEXT_HTML)
260254
.expectBody(String.class).returnResult().getResponseBody();
261255
assertThat(body).contains("Whitelabel Error Page")
262256
.contains("type=Not Found, status=404");
@@ -276,17 +270,13 @@ public void responseCommitted() {
276270

277271
@Test
278272
public void whilelabelDisabled() {
279-
this.contextRunner
280-
.withPropertyValues("server.error.whitelabel.enabled=false",
281-
"spring.mustache.prefix=classpath:/unknown/")
282-
.run((context) -> {
283-
WebTestClient client = WebTestClient.bindToApplicationContext(context)
284-
.build();
285-
client.get().uri("/notfound")
286-
.accept(MediaType.TEXT_HTML).exchange()
287-
.expectStatus().isNotFound()
288-
.expectBody().isEmpty();
289-
});
273+
this.contextRunner.withPropertyValues("server.error.whitelabel.enabled=false",
274+
"spring.mustache.prefix=classpath:/unknown/").run((context) -> {
275+
WebTestClient client = WebTestClient.bindToApplicationContext(context)
276+
.build();
277+
client.get().uri("/notfound").accept(MediaType.TEXT_HTML).exchange()
278+
.expectStatus().isNotFound().expectBody().isEmpty();
279+
});
290280
}
291281

292282
@Configuration

Diff for: spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SpringConfigurationPropertySourcesTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)