feat: code clean. (#11337)

This commit is contained in:
blake.qiu 2023-11-24 14:14:32 +08:00 committed by GitHub
parent 7ce177486f
commit da2b897961
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,7 +45,6 @@ import com.alibaba.nacos.plugin.auth.constant.ActionTypes;
import com.alibaba.nacos.plugin.auth.constant.SignType;
import org.springframework.stereotype.Component;
import java.io.PrintWriter;
import java.net.URLEncoder;
import static com.alibaba.nacos.config.server.constant.Constants.ENCODE_UTF8;
@ -112,7 +111,6 @@ public class ConfigQueryRequestHandler extends RequestHandler<ConfigQueryRequest
int lockResult = tryConfigReadLock(groupKey);
String pullEvent = ConfigTraceService.PULL_EVENT;
boolean isBeta = false;
boolean isSli = false;
if (lockResult > 0) {
try {
String md5 = Constants.NULL;
@ -128,7 +126,6 @@ public class ConfigQueryRequestHandler extends RequestHandler<ConfigQueryRequest
}
String content = null;
ConfigInfoBase configInfoBase = null;
PrintWriter out = null;
if (isBeta) {
md5 = cacheItem.getConfigCacheBeta().getMd5(acceptCharset);
lastModified = cacheItem.getConfigCacheBeta().getLastModifiedTs();
@ -167,20 +164,13 @@ public class ConfigQueryRequestHandler extends RequestHandler<ConfigQueryRequest
}
pullEvent = ConfigTraceService.PULL_EVENT;
if (configInfoBase == null && content == null) {
// FIXME CacheItem
// No longer exists. It is impossible to simply calculate the push delayed. Here, simply record it as - 1.
ConfigTraceService.logPullEvent(dataId, group, tenant, requestIpApp, -1, pullEvent,
ConfigTraceService.PULL_TYPE_NOTFOUND, -1, clientIp, false, "grpc");
// pullLog.info("[client-get] clientIp={}, {},
// no data",
// new Object[]{clientIp, groupKey});
response.setErrorInfo(ConfigQueryResponse.CONFIG_NOT_FOUND, "config data not exist");
return response;
}
isSli = true;
}
} else {
if (cacheItem != null) {
@ -195,18 +185,12 @@ public class ConfigQueryRequestHandler extends RequestHandler<ConfigQueryRequest
response.setTag(tag);
pullEvent = ConfigTraceService.PULL_EVENT_TAG + "-" + tag;
if (configInfoBase == null && content == null) {
// FIXME CacheItem
// No longer exists. It is impossible to simply calculate the push delayed. Here, simply record it as - 1.
ConfigTraceService.logPullEvent(dataId, group, tenant, requestIpApp, -1, pullEvent,
ConfigTraceService.PULL_TYPE_NOTFOUND, -1, clientIp, false, "grpc");
// pullLog.info("[client-get] clientIp={}, {},
// no data",
// new Object[]{clientIp, groupKey});
response.setErrorInfo(ConfigQueryResponse.CONFIG_NOT_FOUND, "config data not exist");
return response;
}
}
}
@ -218,17 +202,10 @@ public class ConfigQueryRequestHandler extends RequestHandler<ConfigQueryRequest
response.setLastModified(lastModified);
response.setContent(configInfoBase.getContent());
response.setResultCode(ResponseCode.SUCCESS.getCode());
} else {
//read from file
try {
response.setContent(content);
response.setLastModified(lastModified);
response.setResultCode(ResponseCode.SUCCESS.getCode());
} catch (Exception e) {
response.setErrorInfo(ResponseCode.FAIL.getCode(), e.getMessage());
return response;
}
response.setContent(content);
response.setLastModified(lastModified);
response.setResultCode(ResponseCode.SUCCESS.getCode());
}
LogUtil.PULL_CHECK_LOG.warn("{}|{}|{}|{}", groupKey, clientIp, md5, TimeUtils.getCurrentTimeStr());
@ -236,7 +213,6 @@ public class ConfigQueryRequestHandler extends RequestHandler<ConfigQueryRequest
final long delayed = System.currentTimeMillis() - lastModified;
if (notify) {
ConfigTraceService.logPullEvent(dataId, group, tenant, requestIpApp, lastModified, pullEvent,
ConfigTraceService.PULL_TYPE_OK, delayed, clientIp, notify, "grpc");
} else {
@ -266,8 +242,7 @@ public class ConfigQueryRequestHandler extends RequestHandler<ConfigQueryRequest
if (cacheItem == null) {
return null;
}
String encryptedDataKey = null;
String encryptedDataKey;
if (isBeta && cacheItem.getConfigCacheBeta() != null) {
encryptedDataKey = cacheItem.getConfigCacheBeta().getEncryptedDataKey();
} else {
@ -285,7 +260,6 @@ public class ConfigQueryRequestHandler extends RequestHandler<ConfigQueryRequest
encryptedDataKey = cacheItem.getTagEncryptedDataKey(tag);
}
}
return encryptedDataKey;
}