Bug Report Checklist
Description
Following the introduction of useFeignCleintContextId with default true in #20943, the contextId by default fails to resolve a valid service name and throws an exception, e.g.:
Service id not legal hostname (${countries.name})
java.lang.IllegalStateException: Service id not legal hostname (${countries.name})
at org.springframework.util.Assert.state(Assert.java:79)
at org.springframework.cloud.openfeign.FeignClientsRegistrar.getName(FeignClientsRegistrar.java:111)
at org.springframework.cloud.openfeign.FeignClientsRegistrar.getContextId(FeignClientsRegistrar.java:346)
at org.springframework.cloud.openfeign.FeignClientsRegistrar.eagerlyRegisterFeignClientBeanDefinition(FeignClientsRegistrar.java:230)
at org.springframework.cloud.openfeign.FeignClientsRegistrar.registerFeignClient(FeignClientsRegistrar.java:215)
at org.springframework.cloud.openfeign.FeignClientsRegistrar.registerFeignClients(FeignClientsRegistrar.java:204)
at org.springframework.cloud.openfeign.FeignClientsRegistrar.registerBeanDefinitions(FeignClientsRegistrar.java:154)
at org.springframework.context.annotation.ImportBeanDefinitionRegistrar.registerBeanDefinitions(ImportBeanDefinitionRegistrar.java:86)
This is with org.springframework.cloud:spring-cloud-starter-openfeign:4.3.0
The generated feign client looks like this:
@FeignClient(name="${countries.name:countries}", contextId="${countries.contextId:${countries.name}}", configuration = ClientConfiguration.class)
public interface CountriesApiClient extends CountriesApi {
}
openapi-generator version
7.13.0
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
#20943
Suggest a fix
Is it possible for the contextId to actually resolve the nested countries.name expression or is it doomed to fail? In any case, I think it would be better to default this new option to false rather than true.
Bug Report Checklist
Description
Following the introduction of
useFeignCleintContextIdwith default true in #20943, the contextId by default fails to resolve a valid service name and throws an exception, e.g.:This is with org.springframework.cloud:spring-cloud-starter-openfeign:4.3.0
The generated feign client looks like this:
openapi-generator version
7.13.0
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
#20943
Suggest a fix
Is it possible for the contextId to actually resolve the nested
countries.nameexpression or is it doomed to fail? In any case, I think it would be better to default this new option tofalserather thantrue.