OpenFeign / OpenFeign/feign

Feign retries event if Retryer.NEVER_RETRY is configured in the AsyncFeign.<HttpClientContext>builder()

Open
#1,966 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hello everyone!

We have run several tests with Feign async clients and even though we are configuring the AsyncFeign builder to not use retries. It worked correctly in most of the cases but when a HttpStatus SERVICE_UNAVAILABLE or TOO_MANY_REQUESTS is returned in the response it retries at least once:

  • org.springframework.boot:spring-boot-starter-parent: 3.0.2
  • org.springframework.cloud:spring-cloud-dependencies: 2022.0.1

Sample of code

import static feign.Retryer.NEVER_RETRY;

@Bean
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public AsyncFeign.AsyncBuilder<HttpClientContext> defaultAsyncBuilder(AsyncClient<HttpClientContext> httpClient, Decoder decoder, Encoder encoder, Contract contract, ErrorDecoder errorDecoder, GlobalFeignRequestInterceptor globalFeignRequestInterceptor) {
              return AsyncFeign.<HttpClientContext>builder()
                          .client(httpClient)
                          .decoder(decoder)
                .errorDecoder(errorDecoder)
                .encoder(encoder)
                .dismiss404()
                .retryer(NEVER_RETRY) // Disable Feign retries
                .contract(contract)
                .requestInterceptor(globalFeignRequestInterceptor);
    }
cloud:
    openfeign:
      httpclient:
        max-connections-per-route: 5
        max-connections: 20
      client:
        config:
          default:
            loggerLevel: full 
            connectTimeout: 60
            readTimeout: 300
            dismiss404: true
          productFeignClient:
            connectTimeout: 10
            readTimeout: 20
            logger-level: full

Are we missing something or is this a known or unknown issue?

Thank you in advance for your answer

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 the AsyncFeign.builder() configuration shown in the report and trace how Retryer.NEVER_RETRY is handled for asynchronous requests. Reproduce the behavior with SERVICE_UNAVAILABLE and TOO_MANY_REQUESTS responses. Done means those responses do not trigger another request when NEVER_RETRY is configured.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.