When I registered a "myApp" service on consumer, because I didn't set the port number, spring cloud consumer discovery threw a NullPointerException when reading the service and creating a DefaultServiceInstance. Later, I found that it was because the port of the DefaultServiceInstance constructor was of type "int" rather than "Integer", so when our port was null, the reading of the service would fail, Therefore, I think spring cloud consumer discovery should filter out such illegal instances and ensure that other instances of the service are still read successfully.
Here I attach the exception stack information:
java.lang.NullPointerException: null
at org.springframework.cloud.consul.discovery.ConsulServiceInstance.<init>(ConsulServiceInstance.java:37) ~[spring-cloud-consul-discovery-3.0.4.jar:3.0.4]
at org.springframework.cloud.consul.discovery.reactive.ConsulReactiveDiscoveryClient.lambda$getInstances$0(ConsulReactiveDiscoveryClient.java:69) ~[spring-cloud-consul-discovery-3.0.4.jar:3.0.4]
at reactor.core.publisher.FluxDefer.subscribe(FluxDefer.java:46) ~[reactor-core-3.4.14.jar:3.4.14]
Here is also a screenshot of the Consul service registration:
When I registered a "myApp" service on consumer, because I didn't set the port number, spring cloud consumer discovery threw a NullPointerException when reading the service and creating a DefaultServiceInstance. Later, I found that it was because the port of the DefaultServiceInstance constructor was of type "int" rather than "Integer", so when our port was null, the reading of the service would fail, Therefore, I think spring cloud consumer discovery should filter out such illegal instances and ensure that other instances of the service are still read successfully.
Here I attach the exception stack information:
Here is also a screenshot of the Consul service registration: