Improve HttpHandlerConnection completion

Before this commit the connector waited for a completed response (via
ServerHttpResponse#setComplete or ServerHttpResponse#writeWith) or an
error signal in handling, but it didn't deal explicitly with the case
where both can occur.

This commit explicitly waits for the completion of handling (success
or error) before passing the response downstream. If an error occurs
after response completion, it is wrapped in a dedicated exception that
also provides access to the completed response.

Close gh-24051
This commit is contained in:
Rossen Stoyanchev
2019-11-22 10:27:38 +00:00
parent b5529f3f2b
commit 21b2fc1f01
3 changed files with 55 additions and 6 deletions

View File

@@ -64,7 +64,7 @@ public class MockClientHttpResponse implements ClientHttpResponse {
}
public MockClientHttpResponse(int status) {
Assert.isTrue(status >= 100 && status < 600, "Status must be between 1xx and 5xx");
Assert.isTrue(status > 99 && status < 1000, "Status must be between 100 and 999");
this.status = status;
}
@@ -148,4 +148,10 @@ public class MockClientHttpResponse implements ClientHttpResponse {
return (charset != null ? charset : StandardCharsets.UTF_8);
}
@Override
public String toString() {
HttpStatus code = HttpStatus.resolve(this.status);
return (code != null ? code.name() + "(" + this.status + ")" : "Status (" + this.status + ")") + this.headers;
}
}