diff --git a/easy-retry-common/easy-retry-common-log/src/main/java/com/aizuda/easy/retry/common/log/lang/StackWalkerCaller.java b/easy-retry-common/easy-retry-common-log/src/main/java/com/aizuda/easy/retry/common/log/lang/StackWalkerCaller.java index 00c90e90d..07c967fd5 100644 --- a/easy-retry-common/easy-retry-common-log/src/main/java/com/aizuda/easy/retry/common/log/lang/StackWalkerCaller.java +++ b/easy-retry-common/easy-retry-common-log/src/main/java/com/aizuda/easy/retry/common/log/lang/StackWalkerCaller.java @@ -1,6 +1,10 @@ package com.aizuda.easy.retry.common.log.lang; +import cn.hutool.core.exceptions.UtilException; + import java.io.Serializable; +import java.util.function.Function; +import java.util.stream.Stream; /** * @author xiaowoniu @@ -11,15 +15,29 @@ public class StackWalkerCaller implements Caller, Serializable { @Override public Class getCaller() { - return null; + StackWalker instance = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE); + StackWalker.StackFrame walk = (StackWalker.StackFrame) instance + .walk((Function, Object>) stackFrameStream -> + stackFrameStream.skip(2).findFirst().get()); + try { + return Class.forName(walk.getClassName()); + } catch (ClassNotFoundException e) { + throw new UtilException(e, "[{}] not found!", walk.getClassName()); + } } @Override public Class getCallerCaller() { StackWalker instance = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE); - Class callerClass = instance.getCallerClass(); - return callerClass; + StackWalker.StackFrame walk = (StackWalker.StackFrame) instance + .walk((Function, Object>) stackFrameStream -> + stackFrameStream.skip(3).findFirst().get()); + try { + return Class.forName(walk.getClassName()); + } catch (ClassNotFoundException e) { + throw new UtilException(e, "[{}] not found!", walk.getClassName()); + } } @Override diff --git a/easy-retry-server/easy-retry-server-job-task/src/main/java/com/aizuda/easy/retry/server/job/task/support/callback/BroadcastClientCallbackHandler.java b/easy-retry-server/easy-retry-server-job-task/src/main/java/com/aizuda/easy/retry/server/job/task/support/callback/BroadcastClientCallbackHandler.java index 0830225ff..176d73118 100644 --- a/easy-retry-server/easy-retry-server-job-task/src/main/java/com/aizuda/easy/retry/server/job/task/support/callback/BroadcastClientCallbackHandler.java +++ b/easy-retry-server/easy-retry-server-job-task/src/main/java/com/aizuda/easy/retry/server/job/task/support/callback/BroadcastClientCallbackHandler.java @@ -1,25 +1,11 @@ package com.aizuda.easy.retry.server.job.task.support.callback; import akka.actor.ActorRef; -import com.aizuda.easy.retry.common.core.enums.JobTaskStatusEnum; -import com.aizuda.easy.retry.common.log.EasyRetryLog; -import com.aizuda.easy.retry.common.log.lang.StackTraceCaller; -import com.aizuda.easy.retry.common.log.lang.StackWalkerCaller; -import com.aizuda.easy.retry.server.common.akka.ActorGenerator; -import com.aizuda.easy.retry.server.common.util.ClientInfoUtils; -import com.aizuda.easy.retry.server.job.task.dto.LogMetaDTO; -import com.aizuda.easy.retry.server.job.task.dto.RealJobExecutorDTO; -import com.aizuda.easy.retry.server.job.task.support.JobTaskConverter; -import com.aizuda.easy.retry.server.job.task.dto.JobExecutorResultDTO; -import com.aizuda.easy.retry.template.datasource.persistence.mapper.JobMapper; -import com.aizuda.easy.retry.template.datasource.persistence.mapper.JobTaskMapper; -import com.aizuda.easy.retry.template.datasource.persistence.po.Job; -import com.aizuda.easy.retry.template.datasource.persistence.po.JobTask; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; import com.aizuda.easy.retry.common.core.enums.JobTaskTypeEnum; +import com.aizuda.easy.retry.server.common.akka.ActorGenerator; +import com.aizuda.easy.retry.server.job.task.dto.JobExecutorResultDTO; +import com.aizuda.easy.retry.server.job.task.support.JobTaskConverter; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** @@ -30,19 +16,6 @@ import org.springframework.stereotype.Component; @Component @Slf4j public class BroadcastClientCallbackHandler extends AbstractClientCallbackHandler { - public static void main(String[] args) { - StackTraceCaller securityManagerCaller = new StackTraceCaller(); - StackWalkerCaller stackWalkerCaller = new StackWalkerCaller(); - Class callerCaller = stackWalkerCaller.getCallerCaller(); - EasyRetryLog.LOCAL.info("aaa"); - System.out.println(callerCaller); - System.out.println(securityManagerCaller.getCallerCaller()); - } - - @Autowired - private JobTaskMapper jobTaskMapper; - @Autowired - private JobMapper jobMapper; @Override public JobTaskTypeEnum getTaskInstanceType() {