Skip to content

Commit

Permalink
[Fix](Job)TVF Query JOB Concurrent Reading and Writing Causes Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
CalvinKirs committed Feb 22, 2024
1 parent b2c0a40 commit 834eb77
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -128,7 +129,7 @@ public AbstractJob(Long jobId, String jobName, JobStatus jobStatus,
this.executeSql = executeSql;
}

private List<T> runningTasks = new ArrayList<>();
private CopyOnWriteArrayList<T> runningTasks = new CopyOnWriteArrayList<>();

private Lock createTaskLock = new ReentrantLock();

Expand All @@ -140,7 +141,7 @@ public void cancelAllTasks() throws JobException {
for (T task : runningTasks) {
task.cancel();
}
runningTasks = new ArrayList<>();
runningTasks = new CopyOnWriteArrayList<>();
}

private static final ImmutableList<String> TITLE_NAMES =
Expand Down Expand Up @@ -270,7 +271,7 @@ public void updateJobStatus(JobStatus newJobStatus) throws JobException {
public static AbstractJob readFields(DataInput in) throws IOException {
String jsonJob = Text.readString(in);
AbstractJob job = GsonUtils.GSON.fromJson(jsonJob, AbstractJob.class);
job.runningTasks = new ArrayList<>();
job.runningTasks = new CopyOnWriteArrayList();
job.createTaskLock = new ReentrantLock();
return job;
}
Expand Down

0 comments on commit 834eb77

Please sign in to comment.