Skip to content

Commit

Permalink
Complete Job Workflows without any children
Browse files Browse the repository at this point in the history
Resolves #11118

getStatus of a workflow job that contains no children crashed because it
was expecting the list of children to be non-null. This fixes resolves
it by making sure that the list is an empty list instead of null.

pr-link: #11117
change-id: cid-bb824a767a143a89adfba852f465a6aa5dcfe9ca
  • Loading branch information
bradyoo committed Mar 4, 2020
1 parent 0ddf70d commit 7567cdd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ private synchronized void stop(long jobId, Status status, String errorMessage) {

private synchronized void next(long jobId) {
WorkflowExecution workflowExecution = mWorkflows.get(jobId);
mChildren.putIfAbsent(jobId, new ConcurrentHashSet<>());

Set<JobConfig> childJobConfigs = workflowExecution.next();

Expand All @@ -232,8 +233,6 @@ private synchronized void next(long jobId) {
}

mWaitingOn.put(jobId, childJobIds);

mChildren.putIfAbsent(jobId, new ConcurrentHashSet<>());
mChildren.get(jobId).addAll(childJobIds);

for (Long childJobId : childJobIds) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ public void before() throws Exception {
mMockJobServerContext = mock(JobServerContext.class);
}

@Test
public void testEmpty() throws Exception {
ArrayList<JobConfig> jobs = Lists.newArrayList();
CompositeConfig config = new CompositeConfig(jobs, true);
mWorkflowTracker.run(config, 0);
WorkflowInfo info = mWorkflowTracker.getStatus(0, true);

assertEquals(Status.COMPLETED, info.getStatus());
}

@Test
public void testBasic() throws Exception {

Expand Down

0 comments on commit 7567cdd

Please sign in to comment.