diff --git a/spring-cloud-modules/spring-cloud-bootstrap/gateway/src/main/java/com/baeldung/spring/cloud/bootstrap/gateway/GatewayApplication.java b/spring-cloud-modules/spring-cloud-bootstrap/gateway/src/main/java/com/baeldung/spring/cloud/bootstrap/gateway/GatewayApplication.java index 79785a3f20..8fc75e1ff6 100644 --- a/spring-cloud-modules/spring-cloud-bootstrap/gateway/src/main/java/com/baeldung/spring/cloud/bootstrap/gateway/GatewayApplication.java +++ b/spring-cloud-modules/spring-cloud-bootstrap/gateway/src/main/java/com/baeldung/spring/cloud/bootstrap/gateway/GatewayApplication.java @@ -1,7 +1,5 @@ package com.baeldung.spring.cloud.bootstrap.gateway; -import com.baeldung.spring.cloud.bootstrap.gateway.client.book.BooksClient; -import com.baeldung.spring.cloud.bootstrap.gateway.client.rating.RatingsClient; import com.netflix.appinfo.InstanceInfo; import com.netflix.discovery.EurekaClient; import org.springframework.beans.factory.annotation.Autowired; @@ -19,8 +17,6 @@ import org.springframework.cloud.sleuth.zipkin.HttpZipkinSpanReporter; import org.springframework.cloud.sleuth.zipkin.ZipkinProperties; import org.springframework.cloud.sleuth.zipkin.ZipkinSpanReporter; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.FilterType; import org.springframework.web.client.RestTemplate; import zipkin.Span; @@ -69,11 +65,10 @@ public class GatewayApplication { @Override public void report(Span span) { InstanceInfo instance = eurekaClient.getNextServerFromEureka("zipkin", false); - if (!(baseUrl != null && instance.getHomePageUrl().equals(baseUrl))) { + if (baseUrl == null || !instance.getHomePageUrl().equals(baseUrl)) { baseUrl = instance.getHomePageUrl(); - delegate = new HttpZipkinSpanReporter(new RestTemplate(), baseUrl, zipkinProperties.getFlushInterval(), spanMetricReporter); - if (!span.name.matches(skipPattern)) delegate.report(span); } + delegate = new HttpZipkinSpanReporter(new RestTemplate(), baseUrl, zipkinProperties.getFlushInterval(), spanMetricReporter); if (!span.name.matches(skipPattern)) delegate.report(span); } }; diff --git a/spring-cloud-modules/spring-cloud-bootstrap/svc-book/src/main/java/com/baeldung/spring/cloud/bootstrap/svcbook/BookServiceApplication.java b/spring-cloud-modules/spring-cloud-bootstrap/svc-book/src/main/java/com/baeldung/spring/cloud/bootstrap/svcbook/BookServiceApplication.java index 91fd23e32d..d787b5e407 100644 --- a/spring-cloud-modules/spring-cloud-bootstrap/svc-book/src/main/java/com/baeldung/spring/cloud/bootstrap/svcbook/BookServiceApplication.java +++ b/spring-cloud-modules/spring-cloud-bootstrap/svc-book/src/main/java/com/baeldung/spring/cloud/bootstrap/svcbook/BookServiceApplication.java @@ -42,11 +42,11 @@ public class BookServiceApplication { @Override public void report(Span span) { InstanceInfo instance = eurekaClient.getNextServerFromEureka("zipkin", false); - if (!(baseUrl != null && instance.getHomePageUrl().equals(baseUrl))) { + if (baseUrl == null || !instance.getHomePageUrl().equals(baseUrl)) { baseUrl = instance.getHomePageUrl(); - delegate = new HttpZipkinSpanReporter(new RestTemplate(), baseUrl, zipkinProperties.getFlushInterval(), spanMetricReporter); - if (!span.name.matches(skipPattern)) delegate.report(span); } + delegate = new HttpZipkinSpanReporter(new RestTemplate(), baseUrl, zipkinProperties.getFlushInterval(), spanMetricReporter); + if (!span.name.matches(skipPattern)) delegate.report(span); } }; } diff --git a/spring-cloud-modules/spring-cloud-bootstrap/svc-rating/src/main/java/com/baeldung/spring/cloud/bootstrap/svcrating/RatingServiceApplication.java b/spring-cloud-modules/spring-cloud-bootstrap/svc-rating/src/main/java/com/baeldung/spring/cloud/bootstrap/svcrating/RatingServiceApplication.java index 8dacbaa79d..5a94f19472 100644 --- a/spring-cloud-modules/spring-cloud-bootstrap/svc-rating/src/main/java/com/baeldung/spring/cloud/bootstrap/svcrating/RatingServiceApplication.java +++ b/spring-cloud-modules/spring-cloud-bootstrap/svc-rating/src/main/java/com/baeldung/spring/cloud/bootstrap/svcrating/RatingServiceApplication.java @@ -51,11 +51,10 @@ public class RatingServiceApplication { @Override public void report(Span span) { InstanceInfo instance = eurekaClient.getNextServerFromEureka("zipkin", false); - if (!(baseUrl != null && instance.getHomePageUrl().equals(baseUrl))) { + if (baseUrl == null || !instance.getHomePageUrl().equals(baseUrl)) { baseUrl = instance.getHomePageUrl(); - delegate = new HttpZipkinSpanReporter(new RestTemplate(), baseUrl, zipkinProperties.getFlushInterval(), spanMetricReporter); - if (!span.name.matches(skipPattern)) delegate.report(span); } + delegate = new HttpZipkinSpanReporter(new RestTemplate(), baseUrl, zipkinProperties.getFlushInterval(), spanMetricReporter); if (!span.name.matches(skipPattern)) delegate.report(span); } };