fix(测试跟踪): 测试计划定时任务执行获取subject报错问题

This commit is contained in:
song-cc-rock 2023-05-05 10:50:56 +08:00 committed by jianxing
parent 459e53cdf9
commit 4661bcbb21

View File

@ -8,6 +8,8 @@ import io.metersphere.plan.dto.ExecutionWay;
import io.metersphere.plan.service.TestPlanService;
import io.metersphere.sechedule.MsScheduleJob;
import io.metersphere.service.BaseUserService;
import org.apache.shiro.mgt.DefaultSecurityManager;
import org.apache.shiro.util.ThreadContext;
import org.quartz.*;
/**
@ -24,6 +26,8 @@ public class TestPlanTestJob extends MsScheduleJob {
private BaseUserService baseUserService;
private static DefaultSecurityManager defaultSecurityManager = new DefaultSecurityManager();
public TestPlanTestJob() {
this.testPlanService = CommonBeanFactory.getBean(TestPlanService.class);
this.baseUserService = CommonBeanFactory.getBean(BaseUserService.class);
@ -45,6 +49,8 @@ public class TestPlanTestJob extends MsScheduleJob {
this.expression = jobDataMap.getString("expression");
this.projectID = jobDataMap.getString("projectId");
// 业务中涉及远程调用, 需在定时任务中获取subject.
ThreadContext.bind(defaultSecurityManager);
businessExecute(context);
}