Skip to content

Commit 26da8c2

Browse files
author
Yang Guo
committed
apply sync for create and update job status
1 parent 8fef5a1 commit 26da8c2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/src/main/java/com/flowci/core/job/service/JobServiceImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public Page<JobItem> list(Flow flow, int page, int size) {
197197
}
198198

199199
@Override
200-
public Job create(Flow flow, String yml, Trigger trigger, StringVars input) {
200+
public synchronized Job create(Flow flow, String yml, Trigger trigger, StringVars input) {
201201
Job job = createJob(flow, trigger, input);
202202
eventManager.publish(new JobCreatedEvent(this, job));
203203

@@ -280,7 +280,7 @@ public boolean isExpired(Job job) {
280280
}
281281

282282
@Override
283-
public Job setJobStatusAndSave(Job job, Job.Status newStatus, String message) {
283+
public synchronized Job setJobStatusAndSave(Job job, Job.Status newStatus, String message) {
284284
if (job.getStatus() == newStatus) {
285285
return jobDao.save(job);
286286
}
@@ -296,6 +296,8 @@ public Job setJobStatusAndSave(Job job, Job.Status newStatus, String message) {
296296
job.getContext().put(Variables.Job.Status, newStatus.name());
297297
jobDao.save(job);
298298
eventManager.publish(new JobStatusChangeEvent(this, job));
299+
300+
log.debug("Job status {} = {}", job.getId(), job.getStatus());
299301
return job;
300302
}
301303

0 commit comments

Comments
 (0)