mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
sonar代码规范问题修复;
This commit is contained in:
+4
-4
@@ -1,6 +1,6 @@
|
||||
package com.cf.imes.framework.env.config;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import com.cf.imes.framework.common.util.collection.SetUtils;
|
||||
import com.cf.imes.framework.env.core.util.EnvUtils;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
@@ -25,20 +25,20 @@ public class EnvEnvironmentPostProcessor implements EnvironmentPostProcessor {
|
||||
@Override
|
||||
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
|
||||
// 0. 设置 ${HOST_NAME} 兜底的环境变量
|
||||
String hostNameKey = StrUtil.subBetween(EnvUtils.HOST_NAME_VALUE, "{", "}");
|
||||
String hostNameKey = CharSequenceUtil.subBetween(EnvUtils.HOST_NAME_VALUE, "{", "}");
|
||||
if (!environment.containsProperty(hostNameKey)) {
|
||||
environment.getSystemProperties().put(hostNameKey, EnvUtils.getHostName());
|
||||
}
|
||||
|
||||
// 1.1 如果没有 chenfeng.env.tag 配置项,则不进行配置项的修改
|
||||
String tag = EnvUtils.getTag(environment);
|
||||
if (StrUtil.isEmpty(tag)) {
|
||||
if (CharSequenceUtil.isEmpty(tag)) {
|
||||
return;
|
||||
}
|
||||
// 1.2 需要修改的配置项
|
||||
for (String targetTagKey : TARGET_TAG_KEYS) {
|
||||
String targetTagValue = environment.getProperty(targetTagKey);
|
||||
if (StrUtil.isNotEmpty(targetTagValue)) {
|
||||
if (CharSequenceUtil.isNotEmpty(targetTagValue)) {
|
||||
continue;
|
||||
}
|
||||
environment.getSystemProperties().put(targetTagKey, tag);
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.cf.imes.framework.env.core.fegin;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import com.cf.imes.framework.common.util.collection.CollectionUtils;
|
||||
import com.cf.imes.framework.env.core.context.EnvContextHolder;
|
||||
import com.cf.imes.framework.env.core.util.EnvUtils;
|
||||
@@ -51,7 +51,7 @@ public class EnvLoadBalancerClient implements ReactorServiceInstanceLoadBalancer
|
||||
public Mono<Response<ServiceInstance>> choose(Request request) {
|
||||
// 情况一,没有 tag 时,使用默认的 reactiveLoadBalancer 实现负载均衡
|
||||
String tag = EnvContextHolder.getTag();
|
||||
if (StrUtil.isEmpty(tag)) {
|
||||
if (CharSequenceUtil.isEmpty(tag)) {
|
||||
return Mono.from(reactiveLoadBalancer.choose(request));
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.cf.imes.framework.env.core.fegin;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import com.cf.imes.framework.env.core.context.EnvContextHolder;
|
||||
import com.cf.imes.framework.env.core.util.EnvUtils;
|
||||
import feign.RequestInterceptor;
|
||||
@@ -16,7 +16,7 @@ public class EnvRequestInterceptor implements RequestInterceptor {
|
||||
@Override
|
||||
public void apply(RequestTemplate requestTemplate) {
|
||||
String tag = EnvContextHolder.getTag();
|
||||
if (StrUtil.isNotEmpty(tag)) {
|
||||
if (CharSequenceUtil.isNotEmpty(tag)) {
|
||||
EnvUtils.setTag(requestTemplate, tag);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.cf.imes.framework.env.core.web;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import com.cf.imes.framework.env.core.context.EnvContextHolder;
|
||||
import com.cf.imes.framework.env.core.util.EnvUtils;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
@@ -24,7 +24,7 @@ public class EnvWebFilter extends OncePerRequestFilter {
|
||||
throws ServletException, IOException {
|
||||
// 如果没有 tag,则走默认的流程
|
||||
String tag = EnvUtils.getTag(request);
|
||||
if (StrUtil.isEmpty(tag)) {
|
||||
if (CharSequenceUtil.isEmpty(tag)) {
|
||||
chain.doFilter(request, response);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user