fix(job-thread): add synchronized block to avoid repeat trigger job

Add synchronized block around triggerLogIdSet check and addition to ensure thread-safety
and prevent repeated job triggers. This update modifies the JobThread class to handle
concurrent access to triggerLogIdSet properly.
3.2.0-release
leqiuhong 1 year ago
parent e5d26ba277
commit c96cb6d41a

@ -59,13 +59,14 @@ public class JobThread extends Thread{
* @return
*/
public ReturnT<String> pushTriggerQueue(TriggerParam triggerParam) {
// avoid repeat
if (triggerLogIdSet.contains(triggerParam.getLogId())) {
logger.info(">>>>>>>>>>> repeate trigger job, logId:{}", triggerParam.getLogId());
return new ReturnT<String>(ReturnT.FAIL_CODE, "repeate trigger job, logId:" + triggerParam.getLogId());
// avoid repeat
synchronized (this){
if (triggerLogIdSet.contains(triggerParam.getLogId())) {
logger.info(">>>>>>>>>>> repeate trigger job, logId:{}", triggerParam.getLogId());
return new ReturnT<String>(ReturnT.FAIL_CODE, "repeate trigger job, logId:" + triggerParam.getLogId());
}
triggerLogIdSet.add(triggerParam.getLogId());
}
triggerLogIdSet.add(triggerParam.getLogId());
triggerQueue.add(triggerParam);
return ReturnT.SUCCESS;
}

Loading…
Cancel
Save