Strengthen the code (#7511)

This commit is contained in:
李晓双 Li Xiao Shuang 2022-01-07 18:09:55 +08:00 committed by GitHub
parent c05f52ccb6
commit 27ed668695
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 14 deletions

View File

@ -33,7 +33,7 @@ public abstract class AbstractNacosTaskExecuteEngine<T extends NacosTask> implem
private final Logger log; private final Logger log;
private final ConcurrentHashMap<Object, NacosTaskProcessor> taskProcessors = new ConcurrentHashMap<Object, NacosTaskProcessor>(); private final ConcurrentHashMap<Object, NacosTaskProcessor> taskProcessors = new ConcurrentHashMap<>();
private NacosTaskProcessor defaultTaskProcessor; private NacosTaskProcessor defaultTaskProcessor;

View File

@ -155,7 +155,7 @@ public class NacosDelayTaskExecuteEngine extends AbstractNacosTaskExecuteEngine<
retryFailedTask(taskKey, task); retryFailedTask(taskKey, task);
} }
} catch (Throwable e) { } catch (Throwable e) {
getEngineLog().error("Nacos task execute error : " + e.toString(), e); getEngineLog().error("Nacos task execute error ", e);
retryFailedTask(taskKey, task); retryFailedTask(taskKey, task);
} }
} }

View File

@ -47,7 +47,7 @@ public class DumpConfigHandler extends Subscriber<ConfigDumpEvent> {
final String type = event.getType(); final String type = event.getType();
final long lastModified = event.getLastModifiedTs(); final long lastModified = event.getLastModifiedTs();
if (event.isBeta()) { if (event.isBeta()) {
boolean result = false; boolean result;
if (event.isRemove()) { if (event.isRemove()) {
result = ConfigCacheService.removeBeta(dataId, group, namespaceId); result = ConfigCacheService.removeBeta(dataId, group, namespaceId);
if (result) { if (result) {

View File

@ -230,8 +230,7 @@ public abstract class DumpService {
} }
} catch (Exception e) { } catch (Exception e) {
LogUtil.FATAL_LOG LogUtil.FATAL_LOG
.error("Nacos Server did not start because dumpservice bean construction failure :\n" + e .error("Nacos Server did not start because dumpservice bean construction failure :\n" + e);
.toString());
throw new NacosException(NacosException.SERVER_ERROR, throw new NacosException(NacosException.SERVER_ERROR,
"Nacos Server did not start because dumpservice bean construction failure :\n" + e.getMessage(), "Nacos Server did not start because dumpservice bean construction failure :\n" + e.getMessage(),
e); e);
@ -337,9 +336,9 @@ public abstract class DumpService {
private Boolean isQuickStart() { private Boolean isQuickStart() {
try { try {
String val = null; String val;
val = EnvUtil.getProperty("isQuickStart"); val = EnvUtil.getProperty("isQuickStart");
if (val != null && TRUE_STR.equals(val)) { if (TRUE_STR.equals(val)) {
isQuickStart = true; isQuickStart = true;
} }
FATAL_LOG.warn("isQuickStart:{}", isQuickStart); FATAL_LOG.warn("isQuickStart:{}", isQuickStart);
@ -404,7 +403,7 @@ public abstract class DumpService {
static List<List<ConfigInfoChanged>> splitList(List<ConfigInfoChanged> list, int count) { static List<List<ConfigInfoChanged>> splitList(List<ConfigInfoChanged> list, int count) {
List<List<ConfigInfoChanged>> result = new ArrayList<List<ConfigInfoChanged>>(count); List<List<ConfigInfoChanged>> result = new ArrayList<List<ConfigInfoChanged>>(count);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
result.add(new ArrayList<ConfigInfoChanged>()); result.add(new ArrayList<>());
} }
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
ConfigInfoChanged config = list.get(i); ConfigInfoChanged config = list.get(i);

View File

@ -67,10 +67,9 @@ public class DumpAllProcessor implements NacosTaskProcessor {
if (cf.getDataId().equals(SwitchService.SWITCH_META_DATAID)) { if (cf.getDataId().equals(SwitchService.SWITCH_META_DATAID)) {
SwitchService.load(cf.getContent()); SwitchService.load(cf.getContent());
} }
boolean result = ConfigCacheService ConfigCacheService.dump(cf.getDataId(), cf.getGroup(), cf.getTenant(), cf.getContent(),
.dump(cf.getDataId(), cf.getGroup(), cf.getTenant(), cf.getContent(), cf.getLastModified(), cf.getLastModified(), cf.getType());
cf.getType());
final String content = cf.getContent(); final String content = cf.getContent();
final String md5 = MD5Utils.md5Hex(content, Constants.ENCODE); final String md5 = MD5Utils.md5Hex(content, Constants.ENCODE);

View File

@ -86,8 +86,8 @@ public class DumpChangeProcessor implements NacosTaskProcessor {
List<ConfigInfoWrapper> changeConfigs = persistService.findChangeConfig(startTime, endTime); List<ConfigInfoWrapper> changeConfigs = persistService.findChangeConfig(startTime, endTime);
LogUtil.DEFAULT_LOG.warn("changeConfig count:{}", changeConfigs.size()); LogUtil.DEFAULT_LOG.warn("changeConfig count:{}", changeConfigs.size());
for (ConfigInfoWrapper cf : changeConfigs) { for (ConfigInfoWrapper cf : changeConfigs) {
boolean result = ConfigCacheService ConfigCacheService.dumpChange(cf.getDataId(), cf.getGroup(), cf.getTenant(), cf.getContent(),
.dumpChange(cf.getDataId(), cf.getGroup(), cf.getTenant(), cf.getContent(), cf.getLastModified()); cf.getLastModified());
final String content = cf.getContent(); final String content = cf.getContent();
final String md5 = MD5Utils.md5Hex(content, Constants.ENCODE); final String md5 = MD5Utils.md5Hex(content, Constants.ENCODE);
LogUtil.DEFAULT_LOG.info("[dump-change-ok] {}, {}, length={}, md5={}", GroupKey2.getKey(cf.getDataId(), cf.getGroup()), LogUtil.DEFAULT_LOG.info("[dump-change-ok] {}, {}, length={}, md5={}", GroupKey2.getKey(cf.getDataId(), cf.getGroup()),