We came across this issue while investigating load balancer statistics with Spring Cloud Gateway. Our build pulls in Spring Cloud Loadbalancer 4.1.5:
java.lang.NullPointerException: Cannot invoke "org.springframework.cloud.client.loadbalancer.Response.getServer()" because the return value of "org.springframework.cloud.client.loadbalancer.CompletionContext.getLoadBalancerResponse()" is null
at org.springframework.cloud.loadbalancer.stats.MicrometerStatsLoadBalancerLifecycle.onComplete(MicrometerStatsLoadBalancerLifecycle.java:96) ~[spring-cloud-loadbalancer-4.1.5.jar:4.1.5]
Suppressed: org.springframework.cloud.gateway.support.NotFoundException: 503 SERVICE_UNAVAILABLE "Unable to find instance for hc-gatewaywithactivehealthchecktest-0-gatewaywithactivehealthchecktest-map-0"
at org.springframework.cloud.gateway.support.NotFoundException.create(NotFoundException.java:45) ~[spring-cloud-gateway-server-4.1.6.jar:4.1.6]
at org.springframework.cloud.gateway.filter.ReactiveLoadBalancerClientFilter.lambda$filter$2(ReactiveLoadBalancerClientFilter.java:123) ~[spring-cloud-gateway-server-4.1.6.jar:4.1.6]
We found the problem when we enabled loadbalancer Micrometer statistics on our gateway instance, which had a test route configured with loadbalancing and a health check. The service that this route resolved to was backed by two k8s pods, both of which were returning a health status of DOWN. So prior to enabling statistics we were receiving the expected 503 response from our test route, since no service instances were available. When we enabled statistics, we began to receive a 500 error instead due to the uncaught NullPointerException.
We came across this issue while investigating load balancer statistics with Spring Cloud Gateway. Our build pulls in Spring Cloud Loadbalancer 4.1.5:
We found the problem when we enabled loadbalancer Micrometer statistics on our gateway instance, which had a test route configured with loadbalancing and a health check. The service that this route resolved to was backed by two k8s pods, both of which were returning a health status of
DOWN. So prior to enabling statistics we were receiving the expected 503 response from our test route, since no service instances were available. When we enabled statistics, we began to receive a 500 error instead due to the uncaughtNullPointerException.