Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Why EncodeException's message is not nullable in 1st constructor but nullable in 2nd constructor?

Open
#2,973 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
java
Domain
api, backend

Research direction

Start by reading the EncodeException constructors and the resolve method in RequestTemplateFactoryResolver, then trace how runtime exceptions with null messages are wrapped. Determine the intended nullability contract for both constructors and verify the behavior around NegativeArraySizeException. Done means the contract and resulting exception message behavior are consistent.

Written by the indexing model from the issue text.

Description

question
  /**
   * @param message the reason for the failure.
   */
  public EncodeException(String message) {
    super(-1, checkNotNull(message, "message"));
  }

  /**
   * @param message possibly null reason for the failure.
   * @param cause the cause of the error.
   */
  public EncodeException(String message, Throwable cause) {
    super(-1, message, checkNotNull(cause, "cause"));
  }

It seems like that EncodeException's message is not null in 1st constructor,
BUT, when a exception with null message is throw (eg. new NegativeArraySizeException() ), you will get a null message EncodeException, such as below codes in RequestTemplateFactoryResolver.

    protected RequestTemplate resolve(Object[] argv, RequestTemplate mutable,
                                      Map<String, Object> variables) {
      Object body = argv[metadata.bodyIndex()];
      checkArgument(body != null, "Body parameter %s was null", metadata.bodyIndex());
      try {
        encoder.encode(body, metadata.bodyType(), mutable);
      } catch (EncodeException e) {
        throw e;
      } catch (RuntimeException e) {
        throw new EncodeException(e.getMessage(), e);
      }
      return super.resolve(argv, mutable, variables);
    }
Dominant language
Java
Stars
9.8k
Forks
2k
Avg merge
12h 8m
Merged PRs (30d)
40

Getting set up

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.

More from OpenFeign/feign

All issues in OpenFeign/feign

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.