Commit 55a8195a by Spencer Gibb

throw more descriptive error if no ServiceInstance is found

parent 936a3b33
......@@ -60,6 +60,9 @@ public class RibbonClientHttpRequestFactory implements ClientHttpRequestFactory
throws IOException {
String serviceId = originalUri.getHost();
ServiceInstance instance = loadBalancer.choose(serviceId);
if (instance == null) {
throw new IllegalStateException("No instances available for "+serviceId);
}
URI uri = loadBalancer.reconstructURI(instance, originalUri);
//@formatter:off
IClientConfig clientConfig = clientFactory.getClientConfig(instance.getServiceId());
......
......@@ -23,6 +23,7 @@ import org.springframework.cloud.client.DefaultServiceInstance;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.cloud.client.loadbalancer.LoadBalancerRequest;
import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;
import com.netflix.loadbalancer.ILoadBalancer;
......@@ -44,6 +45,7 @@ public class RibbonLoadBalancerClient implements LoadBalancerClient {
@Override
public URI reconstructURI(ServiceInstance instance, URI original) {
Assert.notNull(instance, "instance can not be null");
String serviceId = instance.getServiceId();
RibbonLoadBalancerContext context = this.clientFactory
.getLoadBalancerContext(serviceId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment