swagger-api / swagger-api/swagger-codegen

[JAVA] [Feign] Add support for Feign 13

Open
#12,524 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Compilation fails for the Java/Feign generator when Feign 13 and above are used. The reason is version 13 adds an overload to the RetryableException constructor with type Long instead of Date, and the value is passed as null causing the compiler to fail to with following message:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project swagger-petstore-feign: Compilation failure
[ERROR] /Users/lucas.santos/work/code/swagger-codegen/samples/client/petstore/java/feign/src/main/java/io/swagger/client/auth/OAuth.java:[96,19] reference to RetryableException is ambiguous
[ERROR]   both constructor RetryableException(int,java.lang.String,feign.Request.HttpMethod,java.lang.Throwable,java.lang.Long,feign.Request) in feign.RetryableException and constructor RetryableException(int,java.lang.String,feign.Request.HttpMethod,java.lang.Throwable,java.util.Date,feign.Request) in feign.RetryableException match
Description

The solution is simple, in this line:

throw new RetryableException(400, e.getMessage(), template.request().httpMethod(), e, null, template.request());

the type of the 5th parameter must be explicitly specified:

throw new RetryableException(400, e.getMessage(), template.request().httpMethod(), e, (Date) null, template.request());

This solution continues to use the deprecated version but keeps the generator compatible with versions that were already previously supported.

I'll submit Pull Requests

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 with samples/client/petstore/java/feign/src/main/java/io/swagger/client/auth/OAuth.java at the RetryableException call around line 96. Check the Feign 13 constructor overloads and verify compilation with Feign 13 while preserving compatibility with previously supported versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.