@@ -188,20 +188,22 @@ private InnerServiceListener(String service) {
188188 @ Override
189189 public void onEvent (ServiceChangeEvent event ) {
190190 String serviceName = event .getServiceKey ().getService ();
191- List <ServiceInstance > serviceInstances = event .getAllInstances ()
192- .stream ()
193- .map ((Function <Instance , ServiceInstance >) instance -> {
194- DefaultServiceInstance serviceInstance =
195- new DefaultServiceInstance (
196- instance .getService (),
197- instance .getHost (), instance .getPort (),
198- ScopeModelUtil .getApplicationModel (registryURL .getScopeModel ()));
199- serviceInstance .setMetadata (instance .getMetadata ());
200- serviceInstance .setEnabled (!instance .isIsolated ());
201- serviceInstance .setHealthy (instance .isHealthy ());
202- return serviceInstance ;
203- })
204- .collect (Collectors .toList ());
191+ Instance [] instances = operator .getAvailableInstances (serviceName , true );
192+ if (Objects .isNull (instances ) || instances .length == 0 ) {
193+ return ;
194+ }
195+ List <ServiceInstance > serviceInstances = new ArrayList <>(instances .length );
196+ for (Instance instance : instances ) {
197+ DefaultServiceInstance serviceInstance =
198+ new DefaultServiceInstance (
199+ instance .getService (),
200+ instance .getHost (), instance .getPort (),
201+ ScopeModelUtil .getApplicationModel (registryURL .getScopeModel ()));
202+ serviceInstance .setMetadata (instance .getMetadata ());
203+ serviceInstance .setEnabled (!instance .isIsolated ());
204+ serviceInstance .setHealthy (instance .isHealthy ());
205+ serviceInstances .add (serviceInstance );
206+ }
205207
206208 Set <ServiceInstancesChangedListener > listeners = serviceListeners .getOrDefault (service , Collections .emptySet ());
207209
0 commit comments