OpenFeign / OpenFeign/feign

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

Open
#1,210 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug feedback provided
Dominant language
Java
Stars
9.8k
Forks
1.9k
Avg merge
1d 2h
Merged PRs (30d)
41

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the Request and RequestTemplate APIs around requestBody() and body(), then reproduce the null-body example from the issue. Determine the intended nullability behavior for both classes; done should include consistent handling and clear documentation or preconditions for callers.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.