feign
feign copied to clipboard
Can't determine if RequestTemplate or Request has a null body
Hi
In the process of updating feign from version 10.2.3 to 10.7.4, I noticed some deprecation in my codebase on internal code dealing with RequestTemplate
and Request
. The methods RequestTemplate::requestBody
has been marked as deprecated and Request::requestBody
has been removed.
I'm fine with moving on and building something better obviously but it seems there is no non deprecated replacement to detect a null
body in both classes. For example, this simple code will throw a NPE :
public static void main(String[] args)
{
Request.create(HttpMethod.GET,
"http://patate.com",
Collections.emptyMap(),
(Request.Body) null,
(RequestTemplate) null)
.body();
}
If there is a non nullability constraint in both classes, there should be preconditions in the constructors and clear java documentation for users.
Thanks
@jebeaudet
Documentation in the latest version does indicate that body
and requestTemplate
can be null
, however the function Request#body
does not properly check the body
to ensure that it is present. This is an oversight on our part. I've marked this issue as a bug for us to triage and correct. Thanks!
Hello,
I am having the same issue as @jebeaudet. I saw the fix PR was closed, and no other PRs were linked.
Will this issue be tackled? Or do you have any recommendation to check whether a RequestTemplate contains a non body?
Thanks,