Skip to content

Commit e26161d

Browse files
authored
[Client] fix async generic responses (#618)
Fixes error where `asyncBean(Type)` didn't not return an `java.net.http.HttpResponse` instance
1 parent 3f441be commit e26161d

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

http-client/src/main/java/io/avaje/http/client/DHttpClientRequest.java

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -644,35 +644,16 @@ protected HttpResponse<Void> asyncVoid(HttpResponse<byte[]> response) {
644644
return new HttpWrapperResponse<>(response);
645645
}
646646

647-
protected <E> HttpResponse<E> asyncBean(Class<E> type, HttpResponse<byte[]> response) {
647+
protected <E> HttpResponse<E> asyncBean(Type type, HttpResponse<byte[]> response) {
648648
afterAsyncEncoded(response);
649649
return new HttpWrapperResponse<>(context.readBean(type, encodedResponseBody), httpResponse);
650650
}
651651

652-
protected <E> E asyncBean(Type type, HttpResponse<byte[]> response) {
653-
afterAsyncEncoded(response);
654-
return context.readBean(type, encodedResponseBody);
655-
}
656-
657-
protected <E> HttpResponse<List<E>> asyncList(Class<E> type, HttpResponse<byte[]> response) {
658-
afterAsyncEncoded(response);
659-
return new HttpWrapperResponse<>(context.readList(type, encodedResponseBody), httpResponse);
660-
}
661-
662652
protected <E> HttpResponse<List<E>> asyncList(Type type, HttpResponse<byte[]> response) {
663653
afterAsyncEncoded(response);
664654
return new HttpWrapperResponse<>(context.readList(type, encodedResponseBody), httpResponse);
665655
}
666656

667-
protected <E> HttpResponse<Stream<E>> asyncStream(Class<E> type, HttpResponse<Stream<String>> response) {
668-
responseTimeNanos = System.nanoTime() - startAsyncNanos;
669-
httpResponse = response;
670-
context.afterResponse(this);
671-
checkResponse(response);
672-
final BodyReader<E> bodyReader = context.beanReader(type);
673-
return new HttpWrapperResponse<>(response.body().map(bodyReader::readBody), httpResponse);
674-
}
675-
676657
protected <E> HttpResponse<Stream<E>> asyncStream(Type type, HttpResponse<Stream<String>> response) {
677658
responseTimeNanos = System.nanoTime() - startAsyncNanos;
678659
httpResponse = response;
@@ -853,7 +834,7 @@ public String responseBody() {
853834
return context.maxResponseBody(new String(encodedResponseBody.content(), StandardCharsets.UTF_8));
854835
} else if (httpResponse != null && loggableResponseBody) {
855836
final var responseBody = httpResponse.body();
856-
return (responseBody == null) ? null : context.maxResponseBody(responseBody.toString());
837+
return responseBody == null ? null : context.maxResponseBody(responseBody.toString());
857838
}
858839
return null;
859840
}

0 commit comments

Comments
 (0)