Skip to content

Commit 0093e04

Browse files
committed
chore: apply formatting and checkstyle
1 parent 5c592cb commit 0093e04

File tree

2 files changed

+51
-46
lines changed

2 files changed

+51
-46
lines changed

spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/web/servlet/InstancesProxyController.java

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -87,37 +87,42 @@ public InstancesProxyController(String adminContextPath, Set<String> ignoredHead
8787
RequestMethod.PUT, RequestMethod.PATCH, RequestMethod.DELETE, RequestMethod.OPTIONS })
8888
public void instanceProxy(@PathVariable("instanceId") String instanceId, HttpServletRequest servletRequest) {
8989
// start async because we will commit from different thread.
90-
// otherwise incorrect thread local objects (session and security context) will be stored.
91-
// check for example org.springframework.security.web.context.HttpSessionSecurityContextRepository.SaveToSessionRequestWrapper.startAsync()
90+
// otherwise incorrect thread local objects (session and security context) will be
91+
// stored.
92+
// check for example
93+
// org.springframework.security.web.context.HttpSessionSecurityContextRepository.SaveToSessionRequestWrapper.startAsync()
9294
AsyncContext asyncContext = servletRequest.startAsync();
93-
asyncContext.setTimeout(-1); // no timeout because instanceWebProxy will handle it for us
95+
asyncContext.setTimeout(-1); // no timeout because instanceWebProxy will handle it
96+
// for us
9497
try {
95-
ServletServerHttpRequest request = new ServletServerHttpRequest((HttpServletRequest) asyncContext.getRequest());
98+
ServletServerHttpRequest request = new ServletServerHttpRequest(
99+
(HttpServletRequest) asyncContext.getRequest());
96100
Flux<DataBuffer> requestBody = DataBufferUtils.readInputStream(request::getBody, this.bufferFactory, 4096);
97101
InstanceWebProxy.ForwardRequest fwdRequest = createForwardRequest(request, requestBody,
98-
this.adminContextPath + INSTANCE_MAPPED_PATH);
99-
102+
this.adminContextPath + INSTANCE_MAPPED_PATH);
100103

101104
this.instanceWebProxy
102-
.forward(this.registry.getInstance(InstanceId.of(instanceId)), fwdRequest, (clientResponse) -> {
103-
ServerHttpResponse response = new ServletServerHttpResponse((HttpServletResponse) asyncContext.getResponse());
104-
response.setStatusCode(clientResponse.statusCode());
105-
response.getHeaders()
106-
.addAll(this.httpHeadersFilter.filterHeaders(clientResponse.headers().asHttpHeaders()));
107-
try {
108-
OutputStream responseBody = response.getBody();
109-
response.flush();
110-
return clientResponse.body(BodyExtractors.toDataBuffers()).window(1)
111-
.concatMap((body) -> writeAndFlush(body, responseBody)).then();
112-
}
113-
catch (IOException ex) {
114-
return Mono.error(ex);
115-
}
116-
})
117-
// We need to explicitly block so the headers are recieved and written
118-
// before any async dispatch otherwise the FrameworkServlet will add wrong
119-
// Allow header for OPTIONS request
120-
.block();
105+
.forward(this.registry.getInstance(InstanceId.of(instanceId)), fwdRequest, (clientResponse) -> {
106+
ServerHttpResponse response = new ServletServerHttpResponse(
107+
(HttpServletResponse) asyncContext.getResponse());
108+
response.setStatusCode(clientResponse.statusCode());
109+
response.getHeaders()
110+
.addAll(this.httpHeadersFilter.filterHeaders(clientResponse.headers().asHttpHeaders()));
111+
try {
112+
OutputStream responseBody = response.getBody();
113+
response.flush();
114+
return clientResponse.body(BodyExtractors.toDataBuffers()).window(1)
115+
.concatMap((body) -> writeAndFlush(body, responseBody)).then();
116+
}
117+
catch (IOException ex) {
118+
return Mono.error(ex);
119+
}
120+
})
121+
// We need to explicitly block so the headers are recieved and written
122+
// before any async dispatch otherwise the FrameworkServlet will add
123+
// wrong
124+
// Allow header for OPTIONS request
125+
.block();
121126
}
122127
finally {
123128
asyncContext.complete();

spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/web/AbstractInstancesProxyControllerIntegrationTest.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ public void should_return_status_502() {
126126
public void should_return_status_504() {
127127
// 504 on read timeout
128128
this.client.get().uri("/instances/{instanceId}/actuator/timeout", this.instanceId)
129-
.accept(new MediaType(ApiVersion.LATEST.getProducedMimeType()))
130-
.exchange().expectStatus().isEqualTo(HttpStatus.GATEWAY_TIMEOUT);
129+
.accept(new MediaType(ApiVersion.LATEST.getProducedMimeType())).exchange().expectStatus()
130+
.isEqualTo(HttpStatus.GATEWAY_TIMEOUT);
131131
}
132132

133133
@Test
@@ -197,13 +197,13 @@ private void stubForInstance(String managementPath) {
197197

198198
//@formatter:off
199199
String actuatorIndex = "{ \"_links\": { " +
200-
"\"env\": { \"href\": \"" + managementUrl + "/env\", \"templated\": false }," +
201-
"\"test\": { \"href\": \"" + managementUrl + "/test\", \"templated\": false }," +
202-
"\"post\": { \"href\": \"" + managementUrl + "/post\", \"templated\": false }," +
203-
"\"delete\": { \"href\": \"" + managementUrl + "/delete\", \"templated\": false }," +
204-
"\"invalid\": { \"href\": \"" + managementUrl + "/invalid\", \"templated\": false }," +
205-
"\"timeout\": { \"href\": \"" + managementUrl + "/timeout\", \"templated\": false }" +
206-
" } }";
200+
"\"env\": { \"href\": \"" + managementUrl + "/env\", \"templated\": false }," +
201+
"\"test\": { \"href\": \"" + managementUrl + "/test\", \"templated\": false }," +
202+
"\"post\": { \"href\": \"" + managementUrl + "/post\", \"templated\": false }," +
203+
"\"delete\": { \"href\": \"" + managementUrl + "/delete\", \"templated\": false }," +
204+
"\"invalid\": { \"href\": \"" + managementUrl + "/invalid\", \"templated\": false }," +
205+
"\"timeout\": { \"href\": \"" + managementUrl + "/timeout\", \"templated\": false }" +
206+
" } }";
207207
//@formatter:on
208208
this.wireMock.stubFor(get(urlEqualTo(managementPath + "/health")).willReturn(ok("{ \"status\" : \"UP\" }")
209209
.withHeader(CONTENT_TYPE, ApiVersion.LATEST.getProducedMimeType().toString())));
@@ -242,17 +242,17 @@ private String sendRegistration(String managementPath) {
242242

243243
//@formatter:off
244244
String registration = "{ \"name\": \"test\", " +
245-
"\"healthUrl\": \"" + managementUrl + "/health\", " +
246-
"\"managementUrl\": \"" + managementUrl + "\" }";
245+
"\"healthUrl\": \"" + managementUrl + "/health\", " +
246+
"\"managementUrl\": \"" + managementUrl + "\" }";
247247

248248
EntityExchangeResult<Map<String, Object>> result = this.client.post()
249-
.uri("/instances")
250-
.accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON)
251-
.bodyValue(registration)
252-
.exchange()
253-
.expectStatus().isCreated()
254-
.expectBody(RESPONSE_TYPE)
255-
.returnResult();
249+
.uri("/instances")
250+
.accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON)
251+
.bodyValue(registration)
252+
.exchange()
253+
.expectStatus().isCreated()
254+
.expectBody(RESPONSE_TYPE)
255+
.returnResult();
256256
//@formatter:on
257257
assertThat(result.getResponseBody()).containsKeys("id");
258258
return result.getResponseBody().get("id").toString();
@@ -261,9 +261,9 @@ private String sendRegistration(String managementPath) {
261261
private Flux<Map<String, Object>> getEventStream() {
262262
//@formatter:off
263263
return this.client.get().uri("/instances/events").accept(MediaType.TEXT_EVENT_STREAM)
264-
.exchange()
265-
.expectStatus().isOk()
266-
.returnResult(RESPONSE_TYPE).getResponseBody();
264+
.exchange()
265+
.expectStatus().isOk()
266+
.returnResult(RESPONSE_TYPE).getResponseBody();
267267
//@formatter:on
268268
}
269269

0 commit comments

Comments
 (0)