align to checkstyle

pull/251/head
cheese8 3 years ago
parent de3b6d8745
commit 713b6f7baa

@ -76,7 +76,8 @@ public class PolarisFeignLoadBalancer extends FeignLoadBalancer {
try { try {
String labelHeaderValuesContent = labelHeaderValues.stream().findFirst().get(); String labelHeaderValuesContent = labelHeaderValues.stream().findFirst().get();
labelHeaderValuesMap.putAll(JacksonUtils.deserialize2Map(URLDecoder.decode(labelHeaderValuesContent, StandardCharsets.UTF_8.name()))); labelHeaderValuesMap.putAll(JacksonUtils.deserialize2Map(URLDecoder.decode(labelHeaderValuesContent, StandardCharsets.UTF_8.name())));
} catch (UnsupportedEncodingException e) { }
catch (UnsupportedEncodingException e) {
throw new RuntimeException("unsupported charset exception " + StandardCharsets.UTF_8.name()); throw new RuntimeException("unsupported charset exception " + StandardCharsets.UTF_8.name());
} }
routerContext.setLabels(PolarisRouterContext.RULE_ROUTER_LABELS, labelHeaderValuesMap); routerContext.setLabels(PolarisRouterContext.RULE_ROUTER_LABELS, labelHeaderValuesMap);

@ -29,6 +29,7 @@ import feign.RequestInterceptor;
import feign.RequestTemplate; import feign.RequestTemplate;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@ -113,9 +114,10 @@ public class RouterLabelFeignInterceptor implements RequestInterceptor, Ordered
String encodedLabelsContent; String encodedLabelsContent;
try { try {
encodedLabelsContent = URLEncoder.encode(JacksonUtils.serialize2Json(labels), StandardCharsets.UTF_8.name()); encodedLabelsContent = URLEncoder.encode(JacksonUtils.serialize2Json(labels), StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) { }
catch (UnsupportedEncodingException e) {
throw new RuntimeException("unsupported charset exception " + StandardCharsets.UTF_8.name()); throw new RuntimeException("unsupported charset exception " + StandardCharsets.UTF_8.name());
} }
requestTemplate.header(RouterConstants.ROUTER_LABEL_HEADER, encodedLabelsContent); requestTemplate.header(RouterConstants.ROUTER_LABEL_HEADER, encodedLabelsContent);
} }

@ -124,7 +124,8 @@ public class RouterLabelFeignInterceptorTest {
try { try {
String routerLabelContent = routerLabels.stream().findFirst().get(); String routerLabelContent = routerLabels.stream().findFirst().get();
routerLabelsMap.putAll(JacksonUtils.deserialize2Map(URLDecoder.decode(routerLabelContent, StandardCharsets.UTF_8.name()))); routerLabelsMap.putAll(JacksonUtils.deserialize2Map(URLDecoder.decode(routerLabelContent, StandardCharsets.UTF_8.name())));
} catch (UnsupportedEncodingException e) { }
catch (UnsupportedEncodingException e) {
throw new RuntimeException("unsupported charset exception " + StandardCharsets.UTF_8.name()); throw new RuntimeException("unsupported charset exception " + StandardCharsets.UTF_8.name());
} }
Assert.assertNotNull(routerLabelsMap); Assert.assertNotNull(routerLabelsMap);

Loading…
Cancel
Save