spring-cloud/spring-cloud-openfeign

FeignClientFactoryBean dismiss404 default config overrides client-specific config

Bluexin opened this issue · 1 comments

Describe the bug
The way FeignClientFactoryBean handles configuration for dismiss404, it will enable it as soon as any config sets it to true.
The default is applied first, so if it has decode404 that will enable dismiss404. Applying the client-specific config that has decode404 set to false, will not change the value of dismiss404 back.
Relevant code :

if (config.getDismiss404() != null) {
if (config.getDismiss404()) {
builder.dismiss404();
}
}

Sample
Not able to make a full sample right now, I will try to describe it as best as I can :
Clients :

@FeignClient(name = "clientWith404")
interface MyFeignClientWith404

@FeignClient(name = "clientWithout404")
interface MyFeignClientWithout404

application.yml :

feign:
  client:
    config:
      default:
        decode404: true
      clientWithout404:
        decode404: false

(note: this sample might be a bit mixed up between the older version and the new one, I see some changes in the name to dismiss404 but the code handling the config is the same)

From this configuration, I expect clientWith404 to dismiss404, but clientWithout404 not to. In our case we have a lot of clients from internal libraries expecting the default to be true, and one client where this is not the case. Configuring them all individually is a working workaround but quite an error-prone chore.

Thanks @Bluexin, I was able to reproduce it. Wil fix it.