🐛 释放资源.

This commit is contained in:
lijiahangmax
2024-04-22 21:43:12 +08:00
parent f1207be0ec
commit c66e62623e
3 changed files with 6 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ import com.orion.lang.utils.Objects1;
import com.orion.lang.utils.Strings; import com.orion.lang.utils.Strings;
import com.orion.lang.utils.collect.Lists; import com.orion.lang.utils.collect.Lists;
import com.orion.lang.utils.io.Files1; import com.orion.lang.utils.io.Files1;
import com.orion.lang.utils.io.Streams;
import com.orion.ops.framework.biz.operator.log.core.utils.OperatorLogs; import com.orion.ops.framework.biz.operator.log.core.utils.OperatorLogs;
import com.orion.ops.framework.common.constant.Const; import com.orion.ops.framework.common.constant.Const;
import com.orion.ops.framework.common.constant.ErrorMessage; import com.orion.ops.framework.common.constant.ErrorMessage;
@@ -405,6 +406,7 @@ public class ExecLogServiceImpl implements ExecLogService {
@Override @Override
public void downloadLogFile(Long id, String source, HttpServletResponse response) { public void downloadLogFile(Long id, String source, HttpServletResponse response) {
log.info("ExecLogService.downloadLogFile id: {}, source: {}", id, source); log.info("ExecLogService.downloadLogFile id: {}, source: {}", id, source);
InputStream in = null;
try { try {
// 获取主机执行日志 // 获取主机执行日志
ExecHostLogDO hostLog = execHostLogDAO.selectById(id); ExecHostLogDO hostLog = execHostLogDAO.selectById(id);
@@ -418,11 +420,12 @@ public class ExecLogServiceImpl implements ExecLogService {
OperatorLogs.add(OperatorLogs.HOST_ID, hostLog.getHostId()); OperatorLogs.add(OperatorLogs.HOST_ID, hostLog.getHostId());
OperatorLogs.add(OperatorLogs.HOST_NAME, hostLog.getHostName()); OperatorLogs.add(OperatorLogs.HOST_NAME, hostLog.getHostName());
// 获取日志 // 获取日志
InputStream in = logsFileClient.getContentInputStream(logPath); in = logsFileClient.getContentInputStream(logPath);
// 返回 // 返回
Servlets.transfer(response, in, Files1.getFileName(logPath)); Servlets.transfer(response, in, Files1.getFileName(logPath));
} catch (Exception e) { } catch (Exception e) {
log.error("ExecLogService.downloadLogFile error id: {}", id, e); log.error("ExecLogService.downloadLogFile error id: {}", id, e);
Streams.close(in);
String errorMessage = ErrorMessage.FILE_READ_ERROR; String errorMessage = ErrorMessage.FILE_READ_ERROR;
if (e instanceof InvalidArgumentException) { if (e instanceof InvalidArgumentException) {
errorMessage = e.getMessage(); errorMessage = e.getMessage();

View File

@@ -77,8 +77,8 @@
.group-view-container { .group-view-container {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
height: 100%;
width: 100%; width: 100%;
height: 100%;
} }
.host-group-container { .host-group-container {

View File

@@ -60,8 +60,8 @@
.group-view-container { .group-view-container {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
max-height: 100%;
width: 100%; width: 100%;
height: 100%;
} }
.host-group-container { .host-group-container {