diff --git a/spring-cloud-kubernetes-client-discovery/src/main/java/org/springframework/cloud/kubernetes/client/discovery/KubernetesInformerDiscoveryClientAutoConfiguration.java b/spring-cloud-kubernetes-client-discovery/src/main/java/org/springframework/cloud/kubernetes/client/discovery/KubernetesInformerDiscoveryClientAutoConfiguration.java index 046d3a2cdc..3f5d901515 100644 --- a/spring-cloud-kubernetes-client-discovery/src/main/java/org/springframework/cloud/kubernetes/client/discovery/KubernetesInformerDiscoveryClientAutoConfiguration.java +++ b/spring-cloud-kubernetes-client-discovery/src/main/java/org/springframework/cloud/kubernetes/client/discovery/KubernetesInformerDiscoveryClientAutoConfiguration.java @@ -67,8 +67,6 @@ public KubernetesDiscoveryClientHealthIndicatorInitializer indicatorInitializer( } @Deprecated(forRemoval = true) - @Bean - @ConditionalOnMissingBean public KubernetesInformerDiscoveryClient kubernetesInformerDiscoveryClient( KubernetesNamespaceProvider kubernetesNamespaceProvider, SharedInformerFactory sharedInformerFactory, Lister serviceLister, Lister endpointsLister, diff --git a/spring-cloud-kubernetes-client-discovery/src/main/java/org/springframework/cloud/kubernetes/client/discovery/reactive/KubernetesInformerReactiveDiscoveryClient.java b/spring-cloud-kubernetes-client-discovery/src/main/java/org/springframework/cloud/kubernetes/client/discovery/reactive/KubernetesInformerReactiveDiscoveryClient.java index a02be9a460..c883cb5486 100644 --- a/spring-cloud-kubernetes-client-discovery/src/main/java/org/springframework/cloud/kubernetes/client/discovery/reactive/KubernetesInformerReactiveDiscoveryClient.java +++ b/spring-cloud-kubernetes-client-discovery/src/main/java/org/springframework/cloud/kubernetes/client/discovery/reactive/KubernetesInformerReactiveDiscoveryClient.java @@ -16,6 +16,8 @@ package org.springframework.cloud.kubernetes.client.discovery.reactive; +import java.util.Objects; + import io.kubernetes.client.informer.SharedInformer; import io.kubernetes.client.informer.SharedInformerFactory; import io.kubernetes.client.informer.cache.Lister; @@ -29,7 +31,6 @@ import org.springframework.cloud.kubernetes.client.discovery.KubernetesInformerDiscoveryClient; import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider; import org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryProperties; -import org.springframework.util.Assert; /** * @author Ryan Baxter @@ -38,6 +39,7 @@ public class KubernetesInformerReactiveDiscoveryClient implements ReactiveDiscov private final KubernetesInformerDiscoveryClient kubernetesDiscoveryClient; + @Deprecated(forRemoval = true) public KubernetesInformerReactiveDiscoveryClient(KubernetesNamespaceProvider kubernetesNamespaceProvider, SharedInformerFactory sharedInformerFactory, Lister serviceLister, Lister endpointsLister, SharedInformer serviceInformer, @@ -47,6 +49,15 @@ public KubernetesInformerReactiveDiscoveryClient(KubernetesNamespaceProvider kub serviceInformer, endpointsInformer, properties); } + KubernetesInformerReactiveDiscoveryClient( + SharedInformerFactory sharedInformerFactory, Lister serviceLister, + Lister endpointsLister, SharedInformer serviceInformer, + SharedInformer endpointsInformer, KubernetesDiscoveryProperties properties) { + this.kubernetesDiscoveryClient = new KubernetesInformerDiscoveryClient( + sharedInformerFactory, serviceLister, endpointsLister, + serviceInformer, endpointsInformer, properties); + } + @Override public String description() { return "Kubernetes Reactive Discovery Client"; @@ -54,7 +65,7 @@ public String description() { @Override public Flux getInstances(String serviceId) { - Assert.notNull(serviceId, "[Assertion failed] - the object argument must not be null"); + Objects.requireNonNull(serviceId, "serviceId must be provided"); return Flux.defer(() -> Flux.fromIterable(kubernetesDiscoveryClient.getInstances(serviceId))) .subscribeOn(Schedulers.boundedElastic()); } diff --git a/spring-cloud-kubernetes-client-discovery/src/main/java/org/springframework/cloud/kubernetes/client/discovery/reactive/KubernetesInformerReactiveDiscoveryClientAutoConfiguration.java b/spring-cloud-kubernetes-client-discovery/src/main/java/org/springframework/cloud/kubernetes/client/discovery/reactive/KubernetesInformerReactiveDiscoveryClientAutoConfiguration.java index a526d67701..737d8e393c 100644 --- a/spring-cloud-kubernetes-client-discovery/src/main/java/org/springframework/cloud/kubernetes/client/discovery/reactive/KubernetesInformerReactiveDiscoveryClientAutoConfiguration.java +++ b/spring-cloud-kubernetes-client-discovery/src/main/java/org/springframework/cloud/kubernetes/client/discovery/reactive/KubernetesInformerReactiveDiscoveryClientAutoConfiguration.java @@ -74,8 +74,7 @@ public ReactiveDiscoveryClientHealthIndicator kubernetesReactiveDiscoveryClientH return healthIndicator; } - @Bean - @ConditionalOnMissingBean + @Deprecated(forRemoval = true) public KubernetesInformerReactiveDiscoveryClient kubernetesReactiveDiscoveryClient( KubernetesNamespaceProvider kubernetesNamespaceProvider, SharedInformerFactory sharedInformerFactory, Lister serviceLister, Lister endpointsLister, @@ -85,4 +84,15 @@ public KubernetesInformerReactiveDiscoveryClient kubernetesReactiveDiscoveryClie serviceLister, endpointsLister, serviceInformer, endpointsInformer, properties); } + @Bean + @ConditionalOnMissingBean + KubernetesInformerReactiveDiscoveryClient kubernetesClientReactiveDiscoveryClient( + SharedInformerFactory sharedInformerFactory, + Lister serviceLister, Lister endpointsLister, + SharedInformer serviceInformer, SharedInformer endpointsInformer, + KubernetesDiscoveryProperties properties) { + return new KubernetesInformerReactiveDiscoveryClient(sharedInformerFactory, + serviceLister, endpointsLister, serviceInformer, endpointsInformer, properties); + } + }