Describe the bug Using spring cloud openfiegn client

@FeignClient(value ="httpbin2")
public interface TestFeignClient {

    @RequestMapping(value = "/headers", method = RequestMethod.GET)
    String headers();

  • spring boot version: 2.7.13
  • spring cloud : 2021.0.7

When the fiegn client is called, the following service unavailable error occurs

feign.FeignException$ServiceUnavailable: [503] during [GET] to [null://nullhttpbin2/headers] [TestFeignClient#headers()]: [Load balancer does not contain an instance for the service nullhttpbin2]
        at feign.FeignException.serverErrorStatus(FeignException.java:256) ~[feign-core-11.10.jar:na]
        at feign.FeignException.errorStatus(FeignException.java:197) ~[feign-core-11.10.jar:na]
        at feign.FeignException.errorStatus(FeignException.java:185) ~[feign-core-11.10.jar:na]
        at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:92) ~[feign-core-11.10.jar:na]
        at feign.AsyncResponseHandler.handleResponse(AsyncResponseHandler.java:98) ~[feign-core-11.10.jar:na]
        at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:141) ~[feign-core-11.10.jar:na]
        at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:91) ~[feign-core-11.10.jar:na]
        at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:100) ~[feign-core-11.10.jar:na]
        at com.sun.proxy.$Proxy69.headers(Unknown Source) ~[na:na]
        at com.example.demo.TestController.feignHeaders(TestController.java:16) ~[classes/:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_292]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_292]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_292]

I notice this happens becuase the service name happens to start with "http", see FeignClientFactoryBean.getTarget for the logic

It took some time to find where the invalid url is constructed. (My first attempt was to find why "ribbon.client.name" is "nullhttpbin2", then why the clientName is nullhttpbin2 ... and tried all @FeignClient annotation usage to see if I missed something). Note the ribbon part is from an old version of spring boot/cloud.

It's rare that the service name starts with http, however an error reporting in the frist place during startup will be greately helpful.

I don't know if it's worth a more appropriate handling and hence allow service name to start with "http". By the way, inspired by the spring cloud gateway get started examples, I created a service also named httpbin...

Comment From: OlgaMaciaszek

Hello @paulluap, thanks for reporting it. Makes sense. We'll fix it. Btw., Spring Cloud Netflix Ribbon has been out of maintenance for many years now. Please stop using it. It can expose you to security vulnerabilities. Please use Spring Cloud LoadBalancer instead.