Describe the bug
The return type of method kong.unirest.HttpRequest.asEmpty() is HttpResponse, but it should be HttpResponse<Empty>, just like the return type of kong.unirest.HttpRequest.asEmptyAsync() is CompletableFuture<HttpResponse<Empty>> and the return type of kong.unirest.HttpRequest.asString() is HttpResponse<String>.
You get the compiler warning Type safety: The method ifFailure(Consumer) belongs to the raw type HttpResponse. References to generic type HttpResponse<T> should be parameterized and the error The method getStatusText() is undefined for the type Object.
The code can be rewritten to
to make it work, but this prevents method chaining.
If you replace asEmpty() with asString() it also compiles as expected. It's odd that asEmpty() seems to be the only Method in HttpRequest that returns a raw type.
Expected behavior
The return type of method kong.unirest.HttpRequest.asEmpty() is HttpResponse, but it should be HttpResponse<Empty>.
If a response type of HttpResponse<Empty> does not work for some reason (like backwards compatibility) the return type should be at least HttpResponse<?> to allow method chaining.
Describe the bug The return type of method
kong.unirest.HttpRequest.asEmpty()
isHttpResponse
, but it should beHttpResponse<Empty>
, just like the return type ofkong.unirest.HttpRequest.asEmptyAsync()
isCompletableFuture<HttpResponse<Empty>>
and the return type ofkong.unirest.HttpRequest.asString()
isHttpResponse<String>
.To Reproduce The following code does not compile:
You get the compiler warning
Type safety: The method ifFailure(Consumer) belongs to the raw type HttpResponse. References to generic type HttpResponse<T> should be parameterized
and the errorThe method getStatusText() is undefined for the type Object
. The code can be rewritten toto make it work, but this prevents method chaining. If you replace
asEmpty()
withasString()
it also compiles as expected. It's odd thatasEmpty()
seems to be the only Method inHttpRequest
that returns a raw type.Expected behavior The return type of method
kong.unirest.HttpRequest.asEmpty()
isHttpResponse
, but it should beHttpResponse<Empty>
. If a response type ofHttpResponse<Empty>
does not work for some reason (like backwards compatibility) the return type should be at leastHttpResponse<?>
to allow method chaining.Environmental Data: