From 9c99474e84156d795c4295c84e1cb59314d2c125 Mon Sep 17 00:00:00 2001 From: skyehtzhang Date: Fri, 1 Apr 2022 19:42:47 +0800 Subject: [PATCH] fix:fix checkstyle error. --- .../feign/PolarisFeignClientTest.java | 3 +- .../PolarisConfigAutoConfiguration.java | 2 +- .../cloud/polaris/util/OkHttpUtil.java | 5 +-- .../router/PolarisRoutingLoadBalancer.java | 23 +++++++++----- .../cloud/polaris/context/ModifyAddress.java | 31 +++++++++---------- .../context/PolarisContextConfiguration.java | 1 + 6 files changed, 37 insertions(+), 28 deletions(-) diff --git a/spring-cloud-starter-tencent-polaris-circuitbreaker/src/test/java/com/tencent/cloud/polaris/circuitbreaker/feign/PolarisFeignClientTest.java b/spring-cloud-starter-tencent-polaris-circuitbreaker/src/test/java/com/tencent/cloud/polaris/circuitbreaker/feign/PolarisFeignClientTest.java index 757e12001..0c196a53c 100644 --- a/spring-cloud-starter-tencent-polaris-circuitbreaker/src/test/java/com/tencent/cloud/polaris/circuitbreaker/feign/PolarisFeignClientTest.java +++ b/spring-cloud-starter-tencent-polaris-circuitbreaker/src/test/java/com/tencent/cloud/polaris/circuitbreaker/feign/PolarisFeignClientTest.java @@ -37,7 +37,8 @@ import org.springframework.test.context.junit4.SpringRunner; */ @RunWith(SpringRunner.class) @SpringBootTest(classes = TestPolarisFeignApp.class) -@ContextConfiguration(classes = { PolarisFeignClientAutoConfiguration.class, PolarisContextConfiguration.class }) +@ContextConfiguration(classes = { PolarisFeignClientAutoConfiguration.class, + PolarisContextConfiguration.class }) public class PolarisFeignClientTest { @Autowired diff --git a/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/PolarisConfigAutoConfiguration.java b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/PolarisConfigAutoConfiguration.java index eab848b5d..1146e3a84 100644 --- a/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/PolarisConfigAutoConfiguration.java +++ b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/PolarisConfigAutoConfiguration.java @@ -28,7 +28,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** - * polaris config module auto configuration at init application context phase. + * polaris config module auto configuration at init application context phase. * * @author lepdou 2022-03-28 */ diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/util/OkHttpUtil.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/util/OkHttpUtil.java index 0d8e6d665..2a1ba0dc4 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/util/OkHttpUtil.java +++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/util/OkHttpUtil.java @@ -17,11 +17,12 @@ package com.tencent.cloud.polaris.util; +import java.util.Map; +import java.util.Objects; + import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; -import java.util.Map; -import java.util.Objects; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/PolarisRoutingLoadBalancer.java b/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/PolarisRoutingLoadBalancer.java index 9c1246ca4..513557c07 100644 --- a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/PolarisRoutingLoadBalancer.java +++ b/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/PolarisRoutingLoadBalancer.java @@ -17,6 +17,10 @@ package com.tencent.cloud.polaris.router; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + import com.netflix.client.config.IClientConfig; import com.netflix.loadbalancer.DynamicServerListLoadBalancer; import com.netflix.loadbalancer.IPing; @@ -37,10 +41,8 @@ import com.tencent.polaris.api.pojo.ServiceKey; import com.tencent.polaris.router.api.core.RouterAPI; import com.tencent.polaris.router.api.rpc.ProcessRoutersRequest; import com.tencent.polaris.router.api.rpc.ProcessRoutersResponse; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; import org.apache.commons.lang.StringUtils; + import org.springframework.util.CollectionUtils; /** @@ -71,7 +73,8 @@ public class PolarisRoutingLoadBalancer extends DynamicServerListLoadBalancer instances = new ArrayList<>(8); for (Server server : allServers) { DefaultInstance instance = new DefaultInstance(); @@ -102,8 +106,10 @@ public class PolarisRoutingLoadBalancer extends DynamicServerListLoadBalancer transitiveCustomMetadata = MetadataContextHolder.get().getAllTransitiveCustomMetadata(); - String method = MetadataContextHolder.get().getSystemMetadata(SystemMetadataKey.PEER_PATH); + Map transitiveCustomMetadata = MetadataContextHolder.get() + .getAllTransitiveCustomMetadata(); + String method = MetadataContextHolder.get() + .getSystemMetadata(SystemMetadataKey.PEER_PATH); processRoutersRequest.setMethod(method); if (StringUtils.isNotBlank(srcNamespace) && StringUtils.isNotBlank(srcService)) { ServiceInfo serviceInfo = new ServiceInfo(); @@ -112,7 +118,8 @@ public class PolarisRoutingLoadBalancer extends DynamicServerListLoadBalancer filteredInstances = new ArrayList<>(); diff --git a/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/ModifyAddress.java b/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/ModifyAddress.java index 6d3dcf4b9..565849774 100644 --- a/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/ModifyAddress.java +++ b/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/ModifyAddress.java @@ -34,24 +34,23 @@ import org.springframework.beans.factory.annotation.Autowired; */ public class ModifyAddress implements PolarisConfigModifier { - @Autowired - private PolarisContextProperties properties; + @Autowired + private PolarisContextProperties properties; - @Override - public void modify(ConfigurationImpl configuration) { - if (StringUtils.isBlank(properties.getAddress())) { - return; - } - - List addresses = AddressUtils - .parseAddressList(properties.getAddress()); - - configuration.getGlobal().getServerConnector().setAddresses(addresses); + @Override + public void modify(ConfigurationImpl configuration) { + if (StringUtils.isBlank(properties.getAddress())) { + return; } - @Override - public int getOrder() { - return ContextConstant.ModifierOrder.FIRST; - } + List addresses = AddressUtils.parseAddressList(properties.getAddress()); + configuration.getGlobal().getServerConnector().setAddresses(addresses); } + + @Override + public int getOrder() { + return ContextConstant.ModifierOrder.FIRST; + } + +} diff --git a/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/PolarisContextConfiguration.java b/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/PolarisContextConfiguration.java index 63ddd97e8..9b4d3c5f3 100644 --- a/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/PolarisContextConfiguration.java +++ b/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/PolarisContextConfiguration.java @@ -45,4 +45,5 @@ public class PolarisContextConfiguration { public ModifyAddress polarisConfigModifier() { return new ModifyAddress(); } + }