Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ final class DHttpClientContext implements HttpClient, SpiHttpClient {
private final LongAccumulator metricResMaxMicros = new LongAccumulator(Math::max, 0);
private final Function<HttpException, RuntimeException> errorHandler;

private boolean closed;

DHttpClientContext(
java.net.http.HttpClient httpClient,
String baseUrl,
Expand Down Expand Up @@ -86,6 +88,9 @@ public <T> T create(Class<T> clientInterface, ClassLoader classLoader) {

@Override
public HttpClientRequest request() {
if (closed) {
throw new IllegalStateException("HttpClient is closed");
}
return retryHandler == null
? new DHttpClientRequest(this, requestTimeout)
: new DHttpClientRequestWithRetry(this, requestTimeout, retryHandler);
Expand Down Expand Up @@ -389,6 +394,7 @@ String maxResponseBody(String body) {

@Override
public void close() {
this.closed = true;
if (Integer.getInteger("java.specification.version") >= 21) {
try {
MethodHandles.lookup()
Expand Down