[agent][executor]- bug

This commit is contained in:
zeaslity
2023-02-25 18:12:55 +08:00
parent 5e4441fcf1
commit 8bdb40e347

View File

@@ -5,7 +5,6 @@ import io.wdd.common.utils.TimeUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import java.io.BufferedReader;
import java.io.InputStream;
@@ -28,7 +27,7 @@ public class CommandExecLogCache {
/**
* 存储命令执行为空的默认空结果
*/
private static ArrayList<String> EmptyCommandLog = new ArrayList<>();
private static final ArrayList<String> EmptyCommandLog = new ArrayList<>();
/**
* 缓存命令执行日志
@@ -63,7 +62,6 @@ public class CommandExecLogCache {
TimeUtils.currentTimeString()
);
// add the command
commandCachedLog.add("");
commandCachedLog.add(execCommandString);
@@ -71,7 +69,11 @@ public class CommandExecLogCache {
commandCachedLog.add("--------------- command result are as below --------------------");
commandCachedLog.add("");
Assert.notNull(process.getInputStream(),"命令执行结果输出为空!");
log.debug(
"命令执行结果头信息操作完成,内容为 {}",
commandCachedLog
);
// cache the real command logs
doCacheLog(
@@ -92,7 +94,10 @@ public class CommandExecLogCache {
public ArrayList<String> getCacheLog(String streamKey) {
// 获取
ArrayList<String> execLogCacheArrayList = CachedCommandLogMap.getOrDefault(streamKey, EmptyCommandLog);
ArrayList<String> execLogCacheArrayList = CachedCommandLogMap.getOrDefault(
streamKey,
EmptyCommandLog
);
// 清除Key
CachedCommandLogMap.remove(streamKey);