Improve error handling when response is committed

ResponseStatusExceptionHandler lets the error through if it can't
change the status while HttpWebHandlerAdapter logs a more helpful
message (including status code) but without a full stack trace.

Issue: SPR-16231
This commit is contained in:
Rossen Stoyanchev
2017-11-29 12:39:06 -05:00
parent 873cb4e58b
commit dd0d270ba2
3 changed files with 19 additions and 14 deletions

View File

@@ -59,10 +59,9 @@ public class ResponseStatusExceptionHandlerTests {
public void responseCommitted() throws Exception {
Throwable ex = new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Oops");
this.exchange.getResponse().setStatusCode(HttpStatus.CREATED);
this.exchange.getResponse().setComplete()
.then(this.handler.handle(this.exchange, ex))
.block(Duration.ofSeconds(5));
assertEquals(HttpStatus.CREATED, this.exchange.getResponse().getStatusCode());
Mono<Void> mono = this.exchange.getResponse().setComplete()
.then(this.handler.handle(this.exchange, ex));
StepVerifier.create(mono).consumeErrorWith(actual -> assertSame(ex, actual)).verify();
}
}