build(java): 升级Java版本至21并优化虚拟线程使用
- 将项目Java版本从17升级到21 - 替换ThreadUtil.execAsync为Thread.startVirtualThread以利用虚拟线程
This commit is contained in:
+1
-4
@@ -45,14 +45,11 @@ public class CsWsClientManager {
|
||||
CsWsServer wsServer = clientMap.get(sid);
|
||||
if (wsServer != null) {
|
||||
try {
|
||||
// log.info("关闭session, sid={}", sid);
|
||||
log.info("关闭session, sid={}", sid);
|
||||
wsServer.getSession().close();
|
||||
} catch (Exception e) {
|
||||
log.error("Close session failed, sid={}", sid, e);
|
||||
}
|
||||
// log.info("停止任务, sid={}", sid);
|
||||
wsServer.stopTask(sid);
|
||||
// log.info("移除客户端, sid={}", sid);
|
||||
clientMap.remove(sid);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -62,7 +62,7 @@ public class OperationLogAspect {
|
||||
try {
|
||||
Object result = joinPoint.proceed();
|
||||
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, timeInterval);
|
||||
ThreadUtil.execAsync(() -> {
|
||||
Thread.startVirtualThread(() -> {
|
||||
try {
|
||||
systemOperationLogMapper.insert(record);
|
||||
} catch (Exception e) {
|
||||
@@ -73,7 +73,7 @@ public class OperationLogAspect {
|
||||
} catch (Throwable exception) {
|
||||
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, timeInterval);
|
||||
record.setExceptionDetail(ExceptionUtil.stacktraceToString(exception));
|
||||
ThreadUtil.execAsync(() -> {
|
||||
Thread.startVirtualThread(() -> {
|
||||
try {
|
||||
systemOperationLogMapper.insert(record);
|
||||
} catch (Exception e) {
|
||||
|
||||
+2
-2
@@ -62,7 +62,7 @@ public class SystemOperationLogAspect {
|
||||
try {
|
||||
Object result = joinPoint.proceed();
|
||||
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, timeInterval);
|
||||
ThreadUtil.execAsync(() -> {
|
||||
Thread.startVirtualThread(() -> {
|
||||
try {
|
||||
systemOperationLogMapper.insert(record);
|
||||
} catch (Exception e) {
|
||||
@@ -74,7 +74,7 @@ public class SystemOperationLogAspect {
|
||||
} catch (Throwable exception) {
|
||||
SystemOperationLogTb record = getOperationLogTb(joinPoint, annotation, timeInterval);
|
||||
record.setExceptionDetail(ExceptionUtil.stacktraceToString(exception));
|
||||
ThreadUtil.execAsync(() -> {
|
||||
Thread.startVirtualThread(() -> {
|
||||
try {
|
||||
systemOperationLogMapper.insert(record);
|
||||
} catch (Exception e) {
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ public class TaskTestsController {
|
||||
public ResponseEntity<?> testCreateAfterStop() {
|
||||
TaskInstanceInfoTb instanceInfo = taskManage.createJob("cutejava", TaskChangeTypeEnum.AppContainerDeploy, "java", "daily", "cutejava", "功能测试", null);
|
||||
log.info("任务创建成功,实例为:{}", JSON.toJSONString(instanceInfo));
|
||||
ThreadUtil.execAsync(() -> {
|
||||
Thread.startVirtualThread(() -> {
|
||||
ThreadUtil.safeSleep(5000);
|
||||
taskManage.stopJob(instanceInfo.getId());
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||
<java.version>17</java.version>
|
||||
<java.version>21</java.version>
|
||||
<fastjson2.version>2.0.59</fastjson2.version>
|
||||
<druid.version>1.2.27</druid.version>
|
||||
<commons-pool2.version>2.11.1</commons-pool2.version>
|
||||
|
||||
+1
-4
@@ -45,14 +45,11 @@ public class CsWsClientManager {
|
||||
CsWsServer wsServer = clientMap.get(sid);
|
||||
if (wsServer != null) {
|
||||
try {
|
||||
// log.info("关闭session, sid={}", sid);
|
||||
log.info("关闭session, sid={}", sid);
|
||||
wsServer.getSession().close();
|
||||
} catch (Exception e) {
|
||||
log.error("Close session failed, sid={}", sid, e);
|
||||
}
|
||||
// log.info("停止任务, sid={}", sid);
|
||||
wsServer.stopTask(sid);
|
||||
// log.info("移除客户端, sid={}", sid);
|
||||
clientMap.remove(sid);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user