Skip to content

Can't determine if RequestTemplate or Request has a null body #1210

Closed

Description

@jebeaudet

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

Activity

  1. changed the title [-]Can't determine if `RequestTemplate` or `Request` has a `null` body[/-] [+]Can't determine if RequestTemplate or Request has a null body[/+] on Apr 16, 2020
  2. kdavisk6 commented on Apr 25, 2020

    @kdavisk6
    Member

    @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!

  3. added
    bug
    feedback provided
    on Apr 25, 2020
  4. added 3 commits that reference this issue on Jun 9, 2020
  5. Dainerx commented on May 17, 2023

    @Dainerx
    Contributor

    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,

  6. added 2 commits that reference this issue on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfeedback provided

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions