Describe the bug
When the FeignClient.path is set and a url is defined in the properties file, then the incorrect url is constructed. So the call fails with an exception
Steps to reproduce 1. Set up the target host in the properties file
spring.cloud.openfeign.client.config.withPathAndUrlFromConfigClient.url=http://localhost:7777
- Set up the
FeignClient.path(which is a common prefix according to the its javadoc)
@FeignClient(name = "withPathAndUrlFromConfigClient", path = "/common")
interface WithPathAndUrlFromConfigClient {
@GetMapping("/test")
UrlTestClient.UrlResponseForTests test();
}
- Call the
test()method.
Actual result: the exception is thrown
java.lang.IllegalArgumentException: target values must be absolute.
at feign.RequestTemplate.target(RequestTemplate.java:504)
at feign.Target$HardCodedTarget.apply(Target.java:101)
at feign.SynchronousMethodHandler.targetRequest(SynchronousMethodHandler.java:126)
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:91)
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:70)
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:96)
at org.springframework.cloud.openfeign.$Proxy187.test(Unknown Source)
at org.springframework.cloud.openfeign.NonRefreshableFeignClientUrlTests.shouldInstantiateFeignClientWhenUrlFromPropertiesAndPathInTheFeignClientAnnotation(NonRefreshableFeignClientUrlTests.java:93)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
Expected result: the url http://localhost:7777/common/test is called.
Note: when I hardcode the url into the FeignClient.url then it works fine.
Spring Cloud Open Feign version: 4.0.4
Sample https://github.com/spring-cloud/spring-cloud-openfeign/pull/924 demonstrates the issue
Comment From: cbezmen
@OlgaMaciaszek Could you check this PR. 🙂 #939
Comment From: OlgaMaciaszek
Hi @AlexElin - thanks for reporting the issue.
Comment From: OlgaMaciaszek
Closed with commits: - 502613bb740957e9d96feec99077c6ccc0e75351 - bd5701d564662d9c04b20ae87290666b636a63bc - 44657956422bd30deeb4881bf73901a7b906894a - c99923bec2fbd8222eeb131f06d720064a708e5f - 5ccec848a6634295a2950c80c952b8b0c88595b5