fix:fix checkstyle error.

pull/77/head
skyehtzhang 3 years ago
parent 2f0d6a0d6e
commit 9c99474e84

@ -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

@ -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;

@ -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<Se
else {
String serviceName;
// notice the difference between different service registries
if (StringUtils.isNotBlank(allServers.get(0).getMetaInfo().getServiceIdForDiscovery())) {
if (StringUtils.isNotBlank(
allServers.get(0).getMetaInfo().getServiceIdForDiscovery())) {
serviceName = allServers.get(0).getMetaInfo().getServiceIdForDiscovery();
}
else {
@ -81,7 +84,8 @@ public class PolarisRoutingLoadBalancer extends DynamicServerListLoadBalancer<Se
throw new IllegalStateException(
"PolarisRoutingLoadBalancer only Server with AppName or ServiceIdForDiscovery attribute");
}
ServiceKey serviceKey = new ServiceKey(MetadataContext.LOCAL_NAMESPACE, serviceName);
ServiceKey serviceKey = new ServiceKey(MetadataContext.LOCAL_NAMESPACE,
serviceName);
List<Instance> instances = new ArrayList<>(8);
for (Server server : allServers) {
DefaultInstance instance = new DefaultInstance();
@ -102,8 +106,10 @@ public class PolarisRoutingLoadBalancer extends DynamicServerListLoadBalancer<Se
processRoutersRequest.setDstInstances(serviceInstances);
String srcNamespace = MetadataContext.LOCAL_NAMESPACE;
String srcService = MetadataContext.LOCAL_SERVICE;
Map<String, String> transitiveCustomMetadata = MetadataContextHolder.get().getAllTransitiveCustomMetadata();
String method = MetadataContextHolder.get().getSystemMetadata(SystemMetadataKey.PEER_PATH);
Map<String, String> 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<Se
serviceInfo.setMetadata(transitiveCustomMetadata);
processRoutersRequest.setSourceService(serviceInfo);
}
ProcessRoutersResponse processRoutersResponse = routerAPI.processRouters(processRoutersRequest);
ProcessRoutersResponse processRoutersResponse = routerAPI
.processRouters(processRoutersRequest);
ServiceInstances filteredServiceInstances = processRoutersResponse
.getServiceInstances();
List<Server> filteredInstances = new ArrayList<>();

@ -43,8 +43,7 @@ public class ModifyAddress implements PolarisConfigModifier {
return;
}
List<String> addresses = AddressUtils
.parseAddressList(properties.getAddress());
List<String> addresses = AddressUtils.parseAddressList(properties.getAddress());
configuration.getGlobal().getServerConnector().setAddresses(addresses);
}

@ -45,4 +45,5 @@ public class PolarisContextConfiguration {
public ModifyAddress polarisConfigModifier() {
return new ModifyAddress();
}
}

Loading…
Cancel
Save