code: private void finalizeDatasetStateBeforeCommit(JobState.DatasetState datasetState) {
      for (TaskState taskState : datasetState.getTaskStates()) {
        if (taskState.getWorkingState() != WorkUnitState.WorkingState.SUCCESSFUL
            && this.jobContext.getJobCommitPolicy() == JobCommitPolicy.COMMIT_ON_FULL_SUCCESS) {
          // The dataset state is set to FAILED if any task failed and COMMIT_ON_FULL_SUCCESS is used
          datasetState.setState(JobState.RunningState.FAILED);
          datasetState.incrementJobFailures();
          return;
        }
      }
  
      datasetState.setState(JobState.RunningState.SUCCESSFUL);
      datasetState.setNoJobFailure();
    }
docs: Finalize a given {@link JobState.DatasetState} before committing the dataset.
  
  This method is thread-safe.