Buggy code:
public class Task implements Runnable { private static final Logger LOG = LoggerFactory . getLogger ( Task . class ) ; private final String jobId ; private final String taskId ; private final TaskContext taskContext ; private final TaskState taskState ; private final TaskStateTracker taskStateTracker ; private final Optional < CountDownLatch > countDownLatch ; private final List < Optional < Fork > > forks = Lists . newArrayList ( ) ; private final CompletionService forkCompletionService ; private final AtomicInteger retryCount = new AtomicInteger ( ) ; public Task ( TaskContext context , TaskStateTracker taskStateTracker , TaskExecutor taskExecutor , Optional < CountDownLatch > countDownLatch ) { } @ Override @ SuppressWarnings ( "unchecked" ) public void run ( ) { long startTime = System . currentTimeMillis ( ) ; this . taskState . setStartTime ( startTime ) ; this . taskState . setWorkingState ( RUNNING ) ; this . forks . clear ( ) ; Closer closer = Closer . create ( ) ; try { InstrumentedExtractorBase extractor = closer . register ( new gobblin . instrumented . extractor . InstrumentedExtractorDecorator ( this . taskState , this . taskContext . getExtractor ( ) ) ) ; Converter converter = closer . register ( new MultiConverter ( this . taskContext . getConverters ( ) ) ) ; ForkOperator forkOperator = closer . register ( this . taskContext . getForkOperator ( ) ) ; forkOperator . init ( this . taskState ) ; int branches = forkOperator . getBranches ( this . taskState ) ; this . taskState . setProp ( FORK_BRANCHES_KEY , branches ) ; Object schema = converter . convertSchema ( extractor . getSchema ( ) , this . taskState ) ; List < Boolean > forkedSchemas = forkOperator . forkSchema ( this . taskState , schema ) ; if ( ( forkedSchemas . size ( ) ) != branches ) { throw new ForkBranchMismatchException ( String . format ( "Number<seq2seq4repair_space>of<seq2seq4repair_space>forked<seq2seq4repair_space>schemas<seq2seq4repair_space>[%d]<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>equal<seq2seq4repair_space>to<seq2seq4repair_space>number<seq2seq4repair_space>of<seq2seq4repair_space>branches<seq2seq4repair_space>[%d]" , forkedSchemas . size ( ) , branches ) ) ; } if ( ( inMultipleBranches ( forkedSchemas ) ) && ( ! ( schema instanceof Copyable ) ) ) { throw new CopyNotSupportedException ( ( schema + "<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>copyable" ) ) ; } for ( int i = 0 ; i < branches ; i ++ ) { if ( forkedSchemas . get ( i ) ) { Fork fork = closer . register ( new Fork ( this . taskContext , ( schema instanceof Copyable ? ( ( Copyable ) ( schema ) ) . copy ( ) : schema ) , branches , i ) ) ; <START_BUG> this . forkCompletionService . submit ( fork , null ) ; <END_BUG> this . forks . add ( Optional . of ( fork ) ) ; } else { this . forks . add ( Optional . < Fork > absent ( ) ) ; } } RowLevelPolicyChecker rowChecker = closer . register ( this . taskContext . getRowLevelPolicyChecker ( ) ) ; RowLevelPolicyCheckResults rowResults = new RowLevelPolicyCheckResults ( ) ; long recordsPulled = 0 ; Object record ; while ( ( record = extractor . readRecord ( null ) ) != null ) { recordsPulled ++ ; for ( Object convertedRecord : converter . convertRecord ( schema , record , this . taskState ) ) { processRecord ( convertedRecord , forkOperator , rowChecker , rowResults , branches ) ; } } Task . LOG . info ( ( ( "Extracted<seq2seq4repair_space>" + recordsPulled ) + "<seq2seq4repair_space>data<seq2seq4repair_space>records" ) ) ; Task . LOG . info ( ( "Row<seq2seq4repair_space>quality<seq2seq4repair_space>checker<seq2seq4repair_space>finished<seq2seq4repair_space>with<seq2seq4repair_space>results:<seq2seq4repair_space>" + ( rowResults . getResults ( ) ) ) ) ; this . taskState . setProp ( EXTRACTOR_ROWS_EXTRACTED , recordsPulled ) ; this . taskState . setProp ( EXTRACTOR_ROWS_EXPECTED , extractor . getExpectedRecordCount ( ) ) ; for ( Optional < Fork > fork : this . forks ) { if ( fork . isPresent ( ) ) { fork . get ( ) . markParentTaskDone ( ) ; } } for ( Optional < Fork > fork : this . forks ) { if ( fork . isPresent ( ) ) { this . forkCompletionService . take ( ) ; } } boolean allForksSucceeded = true ; for ( Optional < Fork > fork : this . forks ) { if ( fork . isPresent ( ) ) { if ( fork . get ( ) . isSucceeded ( ) ) { if ( ! ( fork . get ( ) . commit ( ) ) ) { allForksSucceeded = false ; } } else { allForksSucceeded = false ; } } } if ( allForksSucceeded ) { this . taskState . setWorkingState ( SUCCESSFUL ) ; } else { Task . LOG . error ( String . format ( "Not<seq2seq4repair_space>all<seq2seq4repair_space>forks<seq2seq4repair_space>of<seq2seq4repair_space>task<seq2seq4repair_space>%s<seq2seq4repair_space>succeeded" , this . taskId ) ) ; this . taskState . setWorkingState ( FAILED ) ; } addConstructsFinalStateToTaskState ( extractor , converter ) ; } catch ( Throwable t ) { failTask ( t ) ; } finally { this . taskState . setProp ( WRITER_RECORDS_WRITTEN , getRecordsWritten ( ) ) ; try { closer . close ( ) ; } catch ( Throwable t ) { Task . LOG . error ( "Failed<seq2seq4repair_space>to<seq2seq4repair_space>close<seq2seq4repair_space>all<seq2seq4repair_space>open<seq2seq4repair_space>resources" , t ) ; } try { if ( shouldPublishDataInTask ( ) ) { publishTaskData ( ) ; this . taskState . setWorkingState ( COMMITTED ) ; } } catch ( IOException ioe ) { failTask ( ioe ) ; } finally { long endTime = System . currentTimeMillis ( ) ; this . taskState . setEndTime ( endTime ) ; this . taskState . setTaskDuration ( ( endTime - startTime ) ) ; this . taskStateTracker . onTaskCompletion ( this ) ; } } } private void failTask ( Throwable t ) { } private boolean shouldPublishDataInTask ( ) { } private void publishTaskData ( ) throws IOException { } public String getJobId ( ) { } public String getTaskId ( ) { } public TaskContext getTaskContext ( ) { }

Fix:
this . forkCompletionService . submit ( fork , fork ) ;