Skip to content

Commit 201fe07

Browse files
committed
chore(deps): 更新 xxl-tool 版本并优化代码依赖- 将 xxl-tool 版本从2.3.0 升级至 2.3.1
- 替换自定义 copy 方法为 IOTool.copy 提高代码复用性 - 移除未使用的 AssertTool依赖 - 使用 StringTool.isBlank 替代手动空值判断- 优化 IP 地址拼接逻辑,提升代码可读性
1 parent a3d4163 commit 201fe07

File tree

3 files changed

+9
-44
lines changed

3 files changed

+9
-44
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<!-- xxl-sso (+xxl-tool、gson) -->
5555
<xxl-sso.version>2.1.1</xxl-sso.version>
5656
<!-- xxl-tool -->
57-
<xxl-tool.version>2.3.0</xxl-tool.version>
57+
<xxl-tool.version>2.3.1</xxl-tool.version>
5858
</properties>
5959

6060
<licenses>

xxl-job-core/src/main/java/com/xxl/job/core/executor/XxlJobExecutor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ private void initEmbedServer(String address, String ip, int port, String appname
153153
// generate address
154154
if (StringTool.isBlank(address)) {
155155
// registry-address:default use address to registry , otherwise use ip:port if address is null
156-
String ip_port_address = IPTool.toAddressString(IPTool.toAddress(ip, port));
156+
String ip_port_address = IPTool.toAddressString(ip, port);
157157
address = "http://{ip_port}/".replace("{ip_port}", ip_port_address);
158158
}
159159

160160
// accessToken
161-
if (accessToken==null || accessToken.trim().length()==0) {
161+
if (StringTool.isBlank(accessToken)) {
162162
logger.warn(">>>>>>>>>>> xxl-job accessToken is empty. To ensure system security, please set the accessToken.");
163163
}
164164

xxl-job-core/src/main/java/com/xxl/job/core/util/ScriptUtil.java

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
import com.xxl.job.core.context.XxlJobHelper;
44
import com.xxl.tool.core.ArrayTool;
5-
import com.xxl.tool.core.AssertTool;
65
import com.xxl.tool.io.FileTool;
6+
import com.xxl.tool.io.IOTool;
77

8-
import java.io.*;
8+
import java.io.FileOutputStream;
9+
import java.io.IOException;
910
import java.util.ArrayList;
1011
import java.util.List;
1112

@@ -83,15 +84,15 @@ public static int execToFile(String command, String scriptFile, String logFile,
8384
final FileOutputStream finalFileOutputStream = fileOutputStream;
8485
inputThread = new Thread(() -> {
8586
try {
86-
copy(finalProcess.getInputStream(), finalFileOutputStream, true, false);
87+
// 数据流Copy(Input自动关闭,Output不处理)
88+
IOTool.copy(finalProcess.getInputStream(), finalFileOutputStream, true, false);
8789
} catch (IOException e) {
8890
XxlJobHelper.log(e);
8991
}
9092
});
9193
errorThread = new Thread(() -> {
9294
try {
93-
// 数据流Copy(Input自动关闭,Output不处理)
94-
copy(finalProcess.getErrorStream(), finalFileOutputStream, true, false);
95+
IOTool.copy(finalProcess.getErrorStream(), finalFileOutputStream, true, false);
9596
} catch (IOException e) {
9697
XxlJobHelper.log(e);
9798
}
@@ -134,42 +135,6 @@ public static int execToFile(String command, String scriptFile, String logFile,
134135
}
135136
}
136137

137-
138-
private static final int BUFFER_SIZE = 1024 * 8;
139-
private static int copy(InputStream input, OutputStream output, boolean closeInput, boolean closeOutput) throws IOException {
140-
AssertTool.notNull(input, "No InputStream specified");
141-
AssertTool.notNull(output, "No OutputStream specified");
142-
143-
try {
144-
int byteCount = 0;
145-
byte[] buffer = new byte[BUFFER_SIZE];
146-
int bytesRead;
147-
while ((bytesRead = input.read(buffer)) != -1) {
148-
output.write(buffer, 0, bytesRead);
149-
byteCount += bytesRead;
150-
}
151-
output.flush();
152-
return byteCount;
153-
} finally {
154-
if (closeInput) {
155-
close(input);
156-
}
157-
if (closeOutput) {
158-
close(output);
159-
}
160-
}
161-
}
162-
private static void close(Closeable closeable) {
163-
if (closeable == null) {
164-
return;
165-
}
166-
try {
167-
closeable.close();
168-
} catch (IOException ex) {
169-
// ignore
170-
}
171-
}
172-
173138
/**
174139
* 脚本执行,日志文件实时输出
175140
*

0 commit comments

Comments
 (0)