chore(deps): 更新 xxl-tool 版本并优化代码依赖- 将 xxl-tool 版本从2.3.0 升级至 2.3.1

- 替换自定义 copy 方法为 IOTool.copy 提高代码复用性
- 移除未使用的 AssertTool依赖
- 使用 StringTool.isBlank 替代手动空值判断- 优化 IP 地址拼接逻辑,提升代码可读性
pull/72/head
xuxueli 1 month ago
parent a3d4163968
commit 201fe07373

@ -54,7 +54,7 @@
<!-- xxl-sso (+xxl-tool、gson) -->
<xxl-sso.version>2.1.1</xxl-sso.version>
<!-- xxl-tool -->
<xxl-tool.version>2.3.0</xxl-tool.version>
<xxl-tool.version>2.3.1</xxl-tool.version>
</properties>
<licenses>

@ -153,12 +153,12 @@ public class XxlJobExecutor {
// generate address
if (StringTool.isBlank(address)) {
// registry-addressdefault use address to registry , otherwise use ip:port if address is null
String ip_port_address = IPTool.toAddressString(IPTool.toAddress(ip, port));
String ip_port_address = IPTool.toAddressString(ip, port);
address = "http://{ip_port}/".replace("{ip_port}", ip_port_address);
}
// accessToken
if (accessToken==null || accessToken.trim().length()==0) {
if (StringTool.isBlank(accessToken)) {
logger.warn(">>>>>>>>>>> xxl-job accessToken is empty. To ensure system security, please set the accessToken.");
}

@ -2,10 +2,11 @@ package com.xxl.job.core.util;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.tool.core.ArrayTool;
import com.xxl.tool.core.AssertTool;
import com.xxl.tool.io.FileTool;
import com.xxl.tool.io.IOTool;
import java.io.*;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@ -83,15 +84,15 @@ public class ScriptUtil {
final FileOutputStream finalFileOutputStream = fileOutputStream;
inputThread = new Thread(() -> {
try {
copy(finalProcess.getInputStream(), finalFileOutputStream, true, false);
// 数据流CopyInput自动关闭Output不处理
IOTool.copy(finalProcess.getInputStream(), finalFileOutputStream, true, false);
} catch (IOException e) {
XxlJobHelper.log(e);
}
});
errorThread = new Thread(() -> {
try {
// 数据流CopyInput自动关闭Output不处理
copy(finalProcess.getErrorStream(), finalFileOutputStream, true, false);
IOTool.copy(finalProcess.getErrorStream(), finalFileOutputStream, true, false);
} catch (IOException e) {
XxlJobHelper.log(e);
}
@ -134,42 +135,6 @@ public class ScriptUtil {
}
}
private static final int BUFFER_SIZE = 1024 * 8;
private static int copy(InputStream input, OutputStream output, boolean closeInput, boolean closeOutput) throws IOException {
AssertTool.notNull(input, "No InputStream specified");
AssertTool.notNull(output, "No OutputStream specified");
try {
int byteCount = 0;
byte[] buffer = new byte[BUFFER_SIZE];
int bytesRead;
while ((bytesRead = input.read(buffer)) != -1) {
output.write(buffer, 0, bytesRead);
byteCount += bytesRead;
}
output.flush();
return byteCount;
} finally {
if (closeInput) {
close(input);
}
if (closeOutput) {
close(output);
}
}
}
private static void close(Closeable closeable) {
if (closeable == null) {
return;
}
try {
closeable.close();
} catch (IOException ex) {
// ignore
}
}
/**
*
*

Loading…
Cancel
Save