8000 NullPointerException in MicrometerStatsLoadBalancerLifecycle · Issue #1453 · spring-cloud/spring-cloud-commons · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

NullPointerException in MicrometerStatsLoadBalancerLifecycle #1453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spikymonkey opened this issue Jan 22, 2025 · 2 comments · Fixed by #1454
Closed

NullPointerException in MicrometerStatsLoadBalancerLifecycle #1453

spikymonkey opened this issue Jan 22, 2025 · 2 comments · Fixed by #1454
Assignees
Labels
Milestone

Comments

@spikymonkey
Copy link

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.

@OlgaMaciaszek
Copy link
Collaborator

Thanks @spikymonkey. Fixed for null-handling. Once you have a sample, feel free to create a separate issue to verify if there's a spot where null response should be swapped for EmptyResponse.

@spikymonkey
Copy link
Author

Will do @OlgaMaciaszek. Thanks for picking this up so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants
0