⚡ AccessLogSaveThread 不再默认启动,AbstractQueueThread 中对非活动状态的线程进行启动,避免重复启动异常
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
package com.hccake.ballcat.common.core.thread;
|
||||
|
||||
import com.hccake.ballcat.common.util.JsonUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextClosedEvent;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 顶级队列线程类
|
||||
*
|
||||
@@ -181,7 +182,9 @@ public abstract class AbstractQueueThread<E> extends Thread
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
// 默认配置线程名. 用来方便查询
|
||||
setName(this.getClass().getSimpleName());
|
||||
start();
|
||||
if (!this.isAlive()) {
|
||||
this.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.hccake.ballcat.log.model.entity.AccessLog;
|
||||
import com.hccake.ballcat.log.thread.AccessLogSaveThread;
|
||||
import com.hccake.ballcat.oauth.SysUserDetails;
|
||||
import com.hccake.ballcat.oauth.util.SecurityUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
@@ -32,13 +31,19 @@ import java.util.Optional;
|
||||
* @date 2019-10-16 16:09:25
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class CustomAccessLogHandler implements AccessLogHandler<AccessLog> {
|
||||
|
||||
private static final String APPLICATION_JSON = "application/json";
|
||||
|
||||
private final AccessLogSaveThread accessLogSaveThread;
|
||||
|
||||
public CustomAccessLogHandler(AccessLogSaveThread accessLogSaveThread) {
|
||||
if (!accessLogSaveThread.isAlive()) {
|
||||
accessLogSaveThread.start();
|
||||
}
|
||||
this.accessLogSaveThread = accessLogSaveThread;
|
||||
}
|
||||
|
||||
/**
|
||||
* 需要脱敏记录的参数
|
||||
*/
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.hccake.ballcat.log.thread;
|
||||
|
||||
import com.hccake.ballcat.common.core.thread.AbstractBlockingQueueThread;
|
||||
import com.hccake.ballcat.log.model.entity.AccessLog;
|
||||
import com.hccake.ballcat.log.service.AccessLogService;
|
||||
import com.hccake.ballcat.common.core.thread.AbstractBlockingQueueThread;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -15,7 +14,6 @@ import java.util.List;
|
||||
* @date 2019/10/16 15:30
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class AccessLogSaveThread extends AbstractBlockingQueueThread<AccessLog> {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user