Skip to content

[JAVA] [Feign] Add support for Feign 13 #12524

Open
@lucasls

Description

@lucasls

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions