Source:
<code>public SqlTask( TaskId taskId, URI location, String nodeId, QueryContext queryContext, SqlTaskExecutionFactory sqlTaskExecutionFactory, ExecutorService taskNotificationExecutor, final Function<SqlTask, ?> onDone, DataSize maxBufferSize, CounterStat failedTasks) { this.taskId = requireNonNull(taskId, "taskId is null"); this.taskInstanceId = UUID.randomUUID().toString(); this.location = requireNonNull(location, "location is null"); this.nodeId = requireNonNull(nodeId, "nodeId is null"); this.queryContext = requireNonNull(queryContext, "queryContext is null"); this.sqlTaskExecutionFactory = requireNonNull(sqlTaskExecutionFactory, "sqlTaskExecutionFactory is null"); requireNonNull(taskNotificationExecutor, "taskNotificationExecutor is null"); requireNonNull(onDone, "onDone is null"); requireNonNull(maxBufferSize, "maxBufferSize is null"); <START> this.failedTasks = requireNonNull(failedTasks, "failed tasks counter is null"); <END> outputBuffer = new LazyOutputBuffer( taskId, taskInstanceId, taskNotificationExecutor, maxBufferSize, () -> queryContext.getTaskContextByTaskId(taskId).localSystemMemoryContext()); taskStateMachine = new TaskStateMachine(taskId, taskNotificationExecutor); taskStateMachine.addStateChangeListener(new StateChangeListener<TaskState>() { @Override public void stateChanged(TaskState newState) { if (!newState.isDone()) { return; } if (newState == TaskState.FAILED) { failedTasks.update(1); } while (true) { TaskHolder taskHolder = taskHolderReference.get(); if (taskHolder.isFinished()) { return; } if (taskHolderReference.compareAndSet(taskHolder, new TaskHolder(createTaskInfo(taskHolder), taskHolder.getIoStats()))) { break; } } if (newState == TaskState.FAILED || newState == TaskState.ABORTED) { outputBuffer.fail(); } else { outputBuffer.destroy(); } try { onDone.apply(SqlTask.this); } catch (Exception e) { log.warn(e, "Error running task cleanup callback %s", SqlTask.this.taskId); } } }); }</code><technical_language>nit: "failedTasks is null" (to consistent)</technical_language>

Target:
public SqlTask( TaskId taskId, URI location, String nodeId, QueryContext queryContext, SqlTaskExecutionFactory sqlTaskExecutionFactory, ExecutorService taskNotificationExecutor, final Function<SqlTask, ?> onDone, DataSize maxBufferSize, CounterStat failedTasks) { this.taskId = requireNonNull(taskId, "taskId is null"); this.taskInstanceId = UUID.randomUUID().toString(); this.location = requireNonNull(location, "location is null"); this.nodeId = requireNonNull(nodeId, "nodeId is null"); this.queryContext = requireNonNull(queryContext, "queryContext is null"); this.sqlTaskExecutionFactory = requireNonNull(sqlTaskExecutionFactory, "sqlTaskExecutionFactory is null"); requireNonNull(taskNotificationExecutor, "taskNotificationExecutor is null"); requireNonNull(onDone, "onDone is null"); requireNonNull(maxBufferSize, "maxBufferSize is null"); this.failedTasks = requireNonNull(failedTasks, "failedTasks is null"); outputBuffer = new LazyOutputBuffer( taskId, taskInstanceId, taskNotificationExecutor, maxBufferSize, () -> queryContext.getTaskContextByTaskId(taskId).localSystemMemoryContext()); taskStateMachine = new TaskStateMachine(taskId, taskNotificationExecutor); taskStateMachine.addStateChangeListener(new StateChangeListener<TaskState>() { @Override public void stateChanged(TaskState newState) { if (!newState.isDone()) { return; } if (newState == FAILED) { failedTasks.update(1); } while (true) { TaskHolder taskHolder = taskHolderReference.get(); if (taskHolder.isFinished()) { return; } if (taskHolderReference.compareAndSet(taskHolder, new TaskHolder(createTaskInfo(taskHolder), taskHolder.getIoStats()))) { break; } } if (newState == FAILED || newState == ABORTED) { outputBuffer.fail(); } else { outputBuffer.destroy(); } try { onDone.apply(SqlTask.this); } catch (Exception e) { log.warn(e, "Error running task cleanup callback %s", SqlTask.this.taskId); } } }); }