Skip to content

Commit 688da65

Browse files
committed
Polish
1 parent 70f6c78 commit 688da65

File tree

26 files changed

+244
-225
lines changed

26 files changed

+244
-225
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ public String getBasePath() {
3838
}
3939

4040
public void setBasePath(String basePath) {
41-
this.basePath = basePath;
41+
this.basePath = basePath;
4242
}
4343

4444
}
45-
46-

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/servlet/WebMvcEndpointManagementContextConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ public class WebMvcEndpointManagementContextConfiguration {
5757
@ConditionalOnMissingBean
5858
public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping(
5959
EndpointProvider<WebEndpointOperation> provider,
60-
EndpointMediaTypes endpointMediaTypes,
61-
CorsEndpointProperties corsProperties,
60+
EndpointMediaTypes endpointMediaTypes, CorsEndpointProperties corsProperties,
6261
WebEndpointProperties webEndpointProperties) {
6362
WebMvcEndpointHandlerMapping handlerMapping = new WebMvcEndpointHandlerMapping(
6463
new EndpointMapping(webEndpointProperties.getBasePath()),
65-
provider.getEndpoints(), endpointMediaTypes, getCorsConfiguration(corsProperties));
64+
provider.getEndpoints(), endpointMediaTypes,
65+
getCorsConfiguration(corsProperties));
6666
return handlerMapping;
6767
}
6868

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextAutoConfiguration.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,18 @@
4343

4444
/**
4545
* {@link EnableAutoConfiguration Auto-configuration} for the management context. If the
46-
* {@code management.server.port} is the same as the {@code server.port} the management context
47-
* will be the same as the main application context. If the {@code management.server.port} is
48-
* different to the {@code server.port} the management context will be a separate context
49-
* that has the main application context as its parent.
46+
* {@code management.server.port} is the same as the {@code server.port} the management
47+
* context will be the same as the main application context. If the
48+
* {@code management.server.port} is different to the {@code server.port} the management
49+
* context will be a separate context that has the main application context as its parent.
5050
*
5151
* @author Andy Wilkinson
5252
* @since 2.0.0
5353
*/
5454
@Configuration
5555
@AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE)
56-
@EnableConfigurationProperties({ WebEndpointProperties.class, ManagementServerProperties.class })
56+
@EnableConfigurationProperties({ WebEndpointProperties.class,
57+
ManagementServerProperties.class })
5758
public class ManagementContextAutoConfiguration {
5859

5960
@Configuration
@@ -77,8 +78,8 @@ public void afterSingletonsInstantiated() {
7778
}
7879

7980
private void verifySslConfiguration() {
80-
Boolean enabled = this.environment.getProperty("management.server.ssl.enabled",
81-
Boolean.class, false);
81+
Boolean enabled = this.environment
82+
.getProperty("management.server.ssl.enabled", Boolean.class, false);
8283
Assert.state(!enabled,
8384
"Management-specific SSL cannot be configured as the management "
8485
+ "server is not listening on a separate port");

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointPropertiesTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,3 @@ public void defaultBasePathShouldBeApplication() throws Exception {
3434
}
3535

3636
}
37-

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointIntegrationTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ public void endpointsAreSecureByDefaultWithCustomBasePath() throws Exception {
8585
}
8686

8787
@Test
88-
public void endpointsAreSecureWithActuatorRoleWithCustomBasePath()
89-
throws Exception {
88+
public void endpointsAreSecureWithActuatorRoleWithCustomBasePath() throws Exception {
9089
TestSecurityContextHolder.getContext().setAuthentication(
9190
new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR"));
9291
this.context = new AnnotationConfigWebApplicationContext();

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/context/ShutdownEndpointTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ public void shutdownChild() throws Exception {
7474
EmptyConfig.class).child(EndpointConfig.class)
7575
.web(WebApplicationType.NONE).run();
7676
CountDownLatch latch = context.getBean(EndpointConfig.class).latch;
77-
assertThat(context.getBean(ShutdownEndpoint.class).shutdown()
78-
.get("message")).startsWith("Shutting down");
77+
assertThat(context.getBean(ShutdownEndpoint.class).shutdown().get("message"))
78+
.startsWith("Shutting down");
7979
assertThat(context.isActive()).isTrue();
8080
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
8181
}
@@ -87,8 +87,8 @@ public void shutdownParent() throws Exception {
8787
.web(WebApplicationType.NONE).run();
8888
CountDownLatch parentLatch = context.getBean(EndpointConfig.class).latch;
8989
CountDownLatch childLatch = context.getBean(EmptyConfig.class).latch;
90-
assertThat(context.getBean(ShutdownEndpoint.class).shutdown()
91-
.get("message")).startsWith("Shutting down");
90+
assertThat(context.getBean(ShutdownEndpoint.class).shutdown().get("message"))
91+
.startsWith("Shutting down");
9292
assertThat(context.isActive()).isTrue();
9393
assertThat(parentLatch.await(10, TimeUnit.SECONDS)).isTrue();
9494
assertThat(childLatch.await(10, TimeUnit.SECONDS)).isTrue();

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ private void configureJtaPlatform(Map<String, Object> vendorProperties)
138138
}
139139
}
140140

141-
private void configureProviderDisablesAutocommit(Map<String, Object> vendorProperties) {
141+
private void configureProviderDisablesAutocommit(
142+
Map<String, Object> vendorProperties) {
142143
if (isDataSourceAutoCommitDisabled() && !isJta()) {
143144
vendorProperties.put(PROVIDER_DISABLES_AUTOCOMMIT, "true");
144145
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientProperties.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,15 @@ public String getClientAuthenticationMethod() {
145145
return this.clientAuthenticationMethod;
146146
}
147147

148-
public void setClientAuthenticationMethod(
149-
String clientAuthenticationMethod) {
148+
public void setClientAuthenticationMethod(String clientAuthenticationMethod) {
150149
this.clientAuthenticationMethod = clientAuthenticationMethod;
151150
}
152151

153152
public String getAuthorizationGrantType() {
154153
return this.authorizationGrantType;
155154
}
156155

157-
public void setAuthorizationGrantType(
158-
String authorizationGrantType) {
156+
public void setAuthorizationGrantType(String authorizationGrantType) {
159157
this.authorizationGrantType = authorizationGrantType;
160158
}
161159

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientPropertiesRegistrationAdapter.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,8 @@ private OAuth2ClientPropertiesRegistrationAdapter() {
4747
public static Map<String, ClientRegistration> getClientRegistrations(
4848
OAuth2ClientProperties properties) {
4949
Map<String, ClientRegistration> clientRegistrations = new HashMap<>();
50-
properties.getRegistration().forEach((key, value) -> {
51-
clientRegistrations.put(key,
52-
getClientRegistration(key, value, properties.getProvider()));
53-
});
50+
properties.getRegistration().forEach((key, value) -> clientRegistrations.put(key,
51+
getClientRegistration(key, value, properties.getProvider())));
5452
return clientRegistrations;
5553
}
5654

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
* @since 2.0.0
4747
* @see ErrorAttributes
4848
*/
49-
public abstract class AbstractErrorWebExceptionHandler implements ErrorWebExceptionHandler, InitializingBean {
49+
public abstract class AbstractErrorWebExceptionHandler
50+
implements ErrorWebExceptionHandler, InitializingBean {
5051

5152
private final ApplicationContext applicationContext;
5253

@@ -71,7 +72,8 @@ public AbstractErrorWebExceptionHandler(ErrorAttributes errorAttributes,
7172
this.errorAttributes = errorAttributes;
7273
this.resourceProperties = resourceProperties;
7374
this.applicationContext = applicationContext;
74-
this.templateAvailabilityProviders = new TemplateAvailabilityProviders(applicationContext);
75+
this.templateAvailabilityProviders = new TemplateAvailabilityProviders(
76+
applicationContext);
7577
}
7678

7779
/**
@@ -101,13 +103,14 @@ public void setViewResolvers(List<ViewResolver> viewResolvers) {
101103
}
102104

103105
/**
104-
* Extract the error attributes from the current request, to be used
105-
* to populate error views or JSON payloads.
106+
* Extract the error attributes from the current request, to be used to populate error
107+
* views or JSON payloads.
106108
* @param request the source request
107109
* @param includeStackTrace whether to include the error stacktrace information
108110
* @return the error attributes as a Map.
109111
*/
110-
protected Map<String, Object> getErrorAttributes(ServerRequest request, boolean includeStackTrace) {
112+
protected Map<String, Object> getErrorAttributes(ServerRequest request,
113+
boolean includeStackTrace) {
111114
return this.errorAttributes.getErrorAttributes(request, includeStackTrace);
112115
}
113116

@@ -117,16 +120,16 @@ protected boolean isTraceEnabled(ServerRequest request) {
117120
}
118121

119122
/**
120-
* Render the given error data as a view, using a template view if available
121-
* or a static HTML file if available otherwise. This will return an empty
123+
* Render the given error data as a view, using a template view if available or a
124+
* static HTML file if available otherwise. This will return an empty
122125
* {@code Publisher} if none of the above are available.
123126
* @param viewName the view name
124127
* @param responseBody the error response being built
125128
* @param error the error data as a map
126129
* @return a Publisher of the {@link ServerResponse}
127130
*/
128-
protected Mono<ServerResponse> renderErrorView(String viewName, ServerResponse.BodyBuilder responseBody,
129-
Map<String, Object> error) {
131+
protected Mono<ServerResponse> renderErrorView(String viewName,
132+
ServerResponse.BodyBuilder responseBody, Map<String, Object> error) {
130133
if (isTemplateAvailable(viewName)) {
131134
return responseBody.render(viewName, error);
132135
}
@@ -138,7 +141,8 @@ protected Mono<ServerResponse> renderErrorView(String viewName, ServerResponse.B
138141
}
139142

140143
private boolean isTemplateAvailable(String viewName) {
141-
return this.templateAvailabilityProviders.getProvider(viewName, this.applicationContext) != null;
144+
return this.templateAvailabilityProviders.getProvider(viewName,
145+
this.applicationContext) != null;
142146
}
143147

144148
private Resource resolveResource(String viewName) {
@@ -158,23 +162,23 @@ private Resource resolveResource(String viewName) {
158162

159163
/**
160164
* Render a default HTML "Whitelabel Error Page".
161-
* <p>Useful when no other error view is available in the application.
165+
* <p>
166+
* Useful when no other error view is available in the application.
162167
* @param responseBody the error response being built
163168
* @param error the error data as a map
164169
* @return a Publisher of the {@link ServerResponse}
165170
*/
166-
protected Mono<ServerResponse> renderDefaultErrorView(ServerResponse.BodyBuilder responseBody,
167-
Map<String, Object> error) {
171+
protected Mono<ServerResponse> renderDefaultErrorView(
172+
ServerResponse.BodyBuilder responseBody, Map<String, Object> error) {
168173
StringBuilder builder = new StringBuilder();
169174
Date timestamp = (Date) error.get("timestamp");
170175
builder.append("<html><body><h1>Whitelabel Error Page</h1>")
171176
.append("<p>This application has no configured error view, so you are seeing this as a fallback.</p>")
172-
.append("<div id='created'>").append(timestamp.toString()).append("</div>")
173-
.append("<div>There was an unexpected error (type=")
174-
.append(error.get("error")).append(", status=").append(error.get("status"))
175-
.append(").</div>")
176-
.append("<div>").append(error.get("message")).append("</div>")
177-
.append("</body></html>");
177+
.append("<div id='created'>").append(timestamp.toString())
178+
.append("</div>").append("<div>There was an unexpected error (type=")
179+
.append(error.get("error")).append(", status=")
180+
.append(error.get("status")).append(").</div>").append("<div>")
181+
.append(error.get("message")).append("</div>").append("</body></html>");
178182
return responseBody.syncBody(builder.toString());
179183
}
180184

@@ -188,27 +192,31 @@ public void afterPropertiesSet() throws Exception {
188192
/**
189193
* Create a {@link RouterFunction} that can route and handle errors as JSON responses
190194
* or HTML views.
191-
* <p>If the returned {@link RouterFunction} doesn't route to a {@code HandlerFunction},
195+
* <p>
196+
* If the returned {@link RouterFunction} doesn't route to a {@code HandlerFunction},
192197
* the original exception is propagated in the pipeline and can be processed by other
193198
* {@link org.springframework.web.server.WebExceptionHandler}s.
194-
* @param errorAttributes the {@code ErrorAttributes} instance to use to extract error information
199+
* @param errorAttributes the {@code ErrorAttributes} instance to use to extract error
200+
* information
195201
* @return a {@link RouterFunction} that routes and handles errors
196202
*/
197-
protected abstract RouterFunction<ServerResponse> getRoutingFunction(ErrorAttributes errorAttributes);
203+
protected abstract RouterFunction<ServerResponse> getRoutingFunction(
204+
ErrorAttributes errorAttributes);
198205

199206
@Override
200207
public Mono<Void> handle(ServerWebExchange exchange, Throwable throwable) {
201208

202209
this.errorAttributes.storeErrorInformation(throwable, exchange);
203210
ServerRequest request = ServerRequest.create(exchange, this.messageReaders);
204-
return getRoutingFunction(this.errorAttributes)
205-
.route(request)
211+
return getRoutingFunction(this.errorAttributes).route(request)
206212
.switchIfEmpty(Mono.error(throwable))
207-
.flatMap(handler -> handler.handle(request))
208-
.flatMap(response -> {
209-
// force content-type since writeTo won't overwrite response header values
210-
exchange.getResponse().getHeaders().setContentType(response.headers().getContentType());
213+
.flatMap((handler) -> handler.handle(request)).flatMap((response) -> {
214+
// force content-type since writeTo won't overwrite response header
215+
// values
216+
exchange.getResponse().getHeaders()
217+
.setContentType(response.headers().getContentType());
211218
return response.writeTo(exchange, new ServerResponse.Context() {
219+
212220
@Override
213221
public List<HttpMessageWriter<?>> messageWriters() {
214222
return AbstractErrorWebExceptionHandler.this.messageWriters;
@@ -218,7 +226,9 @@ public List<HttpMessageWriter<?>> messageWriters() {
218226
public List<ViewResolver> viewResolvers() {
219227
return AbstractErrorWebExceptionHandler.this.viewResolvers;
220228
}
229+
221230
});
222231
});
223232
}
233+
224234
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorAttributes.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public DefaultErrorAttributes(boolean includeException) {
7171
}
7272

7373
@Override
74-
public Map<String, Object> getErrorAttributes(ServerRequest request, boolean includeStackTrace) {
74+
public Map<String, Object> getErrorAttributes(ServerRequest request,
75+
boolean includeStackTrace) {
7576
Map<String, Object> errorAttributes = new LinkedHashMap<>();
7677
errorAttributes.put("timestamp", new Date());
7778
errorAttributes.put("path", request.path());
@@ -90,7 +91,8 @@ public Map<String, Object> getErrorAttributes(ServerRequest request, boolean inc
9091
}
9192
else {
9293
errorAttributes.put("status", HttpStatus.INTERNAL_SERVER_ERROR.value());
93-
errorAttributes.put("error", HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase());
94+
errorAttributes.put("error",
95+
HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase());
9496
}
9597
return errorAttributes;
9698
}
@@ -115,7 +117,8 @@ private void addErrorMessage(Map<String, Object> errorAttributes, Throwable erro
115117
@Override
116118
public Throwable getError(ServerRequest request) {
117119
return (Throwable) request.attribute(ERROR_ATTRIBUTE)
118-
.orElseThrow(() -> new IllegalStateException("Missing exception attribute in ServerWebExchange"));
120+
.orElseThrow(() -> new IllegalStateException(
121+
"Missing exception attribute in ServerWebExchange"));
119122
}
120123

121124
@Override

0 commit comments

Comments
 (0)