question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Discovery on all namespaces leads to NullPointerException on service

See original GitHub issue

For a bit of backstory: I’m trying out the new spring.cloud.kubernetes.discovery.all-namespaces=true to retrieve service instances on all namespaces within a single instance of Spring Boot Admin. This seems to work fine if, and only if, all matching services are deployed to all namespaces. If any service is missing on any namespace, I get the following stacktrace:

java.lang.NullPointerException: null
	at org.springframework.cloud.kubernetes.discovery.KubernetesDiscoveryClient.getInstances(KubernetesDiscoveryClient.java:122)
	at org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClient.getInstances(CompositeDiscoveryClient.java:53)
	at reactor.core.publisher.FluxFlattenIterable$FlattenIterableSubscriber.drainSync(FluxFlattenIterable.java:519)
	at reactor.core.publisher.FluxFlattenIterable$FlattenIterableSubscriber.drain(FluxFlattenIterable.java:633)
	at reactor.core.publisher.FluxFlattenIterable$FlattenIterableSubscriber.request(FluxFlattenIterable.java:267)
	at reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.request(FluxFilterFuseable.java:184)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.onSubscribe(FluxFlatMap.java:332)
	at reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.onSubscribe(FluxFilterFuseable.java:81)
	at reactor.core.publisher.FluxFlattenIterable$FlattenIterableSubscriber.onSubscribe(FluxFlattenIterable.java:209)
	at reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.onSubscribe(FluxFilterFuseable.java:81)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:135)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:63)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3920)
	at reactor.core.publisher.Mono.subscribeWith(Mono.java:4030)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3899)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3835)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3807)
	at de.codecentric.boot.admin.server.cloud.discovery.InstanceDiscoveryListener.discover(InstanceDiscoveryListener.java:124)
	at de.codecentric.boot.admin.server.cloud.discovery.InstanceDiscoveryListener.onApplicationReady(InstanceDiscoveryListener.java:91)

Tracing through the code this happens when service is null in this line: https://github.com/spring-cloud/spring-cloud-kubernetes/blob/702c7b2ee83291b71ede94a4862d364cfa6284b6/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClient.java#L122

So while that service might be available on other namespaces, it’s not on the particular namespace queried, leading to null & NPE. Can this be fixed somehow?

My application is pretty minimal; just the most recent snapshots of SBA & SCK8S with the following configuration:

spring.boot.admin.discovery.converter.management-context-path: /
spring.cloud.kubernetes.discovery.all-namespaces: true
spring.cloud.kubernetes.discovery.filter: metadata.name.startsWith('some-prefix')
spring.cloud.kubernetes.discovery.primaryPortName: management

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
michaelmcfadyencommented, Sep 13, 2019

yes, this is the same issue I encountered with #465.

0reactions
timtebeekcommented, Sep 13, 2019

@michaelmcfadyen thanks for confirming and exploring I’m more depth in your ticket… guess that makes this a duplicate that we can close while we wait for the other ticket to be resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NullPointerException during Service Discovery - IBM
Cause. This exception might occur in the following situation: An earlier discovered BO is already available and cannot be updated during  ...
Read more >
NullPointer exception converting SOAP string message to ...
I'm converting an XML string to a SOAPMessage. However, I end up getting a NullPointerException when attempting to invoke the service.
Read more >
NullPointerException - Android Developers
Returns an array containing all of the exceptions that were suppressed, typically by ... Causes the current thread to wait until another thread...
Read more >
Discovery Home page shows "java.lang.NullPointerException ...
This is caused by tables existing in the CMDB according to the records in the sys_db_object table, that don't actually exist in the...
Read more >
Exception on CONNECT SOAP related to Namespace null
I don't understand the reason of the namespace null , i checked the WSDL and all namespace are filled. Any help. Pega Customer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found