Program: 4571
Project: 4571
Buggy source:
/** 
 * Record that a cluster will be provisioned for a program run, returning a Runnable that will actually perform the cluster provisioning. This method must be run within a transaction. The task returned should be run using the   {@link #execute(ProvisioningTask)} method, and should only be executedafter the transaction that ran this method has completed.
 * @param provisionRequest the provision request
 * @param datasetContext dataset context for the transaction
 * @return runnable that will actually execute the cluster provisioning
 */
public ProvisioningTask provision(ProvisionRequest provisionRequest,DatasetContext datasetContext){
  ProgramRunId programRunId=provisionRequest.getProgramRunId();
  ProgramOptions programOptions=provisionRequest.getProgramOptions();
  Map<String,String> args=programOptions.getArguments().asMap();
  String name=SystemArguments.getProfileProvisioner(args);
  Provisioner provisioner=provisionerInfo.get().provisioners.get(name);
  if (provisioner == null) {
    LOG.error("String_Node_Str",programRunId,name);
    provisionerNotifier.deprovisioned(programRunId);
    return new NoOpProvisioningTask(programRunId);
  }
  SSHKeyInfo sshKeyInfo=null;
  if (!YarnProvisioner.SPEC.equals(provisioner.getSpec())) {
    try {
      sshKeyInfo=generateSSHKey(programRunId);
    }
 catch (    Exception e) {
      LOG.error("String_Node_Str",programRunId,name,e);
      provisionerNotifier.deprovisioning(programRunId);
      return new NoOpProvisioningTask(programRunId);
    }
  }
  Map<String,String> properties=SystemArguments.getProfileProperties(args);
  ProvisionerContext context=new DefaultProvisionerContext(programRunId,properties,createSSHContext(sshKeyInfo));
  ClusterOp clusterOp=new ClusterOp(ClusterOp.Type.PROVISION,ClusterOp.Status.REQUESTING_CREATE);
  ClusterInfo clusterInfo=new ClusterInfo(programRunId,provisionRequest.getProgramDescriptor(),properties,name,provisionRequest.getUser(),clusterOp,null,null);
  ProvisionerDataset provisionerDataset=ProvisionerDataset.get(datasetContext,datasetFramework);
  provisionerDataset.putClusterInfo(clusterInfo);
  return new ProvisionTask(provisionRequest,provisioner,context,provisionerNotifier,transactional,datasetFramework,sshKeyInfo);
}

Fixed version (ground truth):
/** 
 * Record that a cluster will be provisioned for a program run, returning a Runnable that will actually perform the cluster provisioning. This method must be run within a transaction. The task returned should be run using the   {@link #execute(ProvisioningTask)} method, and should only be executedafter the transaction that ran this method has completed.
 * @param provisionRequest the provision request
 * @param datasetContext dataset context for the transaction
 * @return runnable that will actually execute the cluster provisioning
 */
public ProvisioningTask provision(ProvisionRequest provisionRequest,DatasetContext datasetContext){
  ProgramRunId programRunId=provisionRequest.getProgramRunId();
  ProgramOptions programOptions=provisionRequest.getProgramOptions();
  Map<String,String> args=programOptions.getArguments().asMap();
  String name=SystemArguments.getProfileProvisioner(args);
  Provisioner provisioner=provisionerInfo.get().provisioners.get(name);
  if (provisioner == null) {
    LOG.error("String_Node_Str",programRunId,name);
    provisionerNotifier.deprovisioned(programRunId);
    return new NoOpProvisioningTask(programRunId);
  }
  SSHKeyInfo sshKeyInfo=null;
  if (!YarnProvisioner.SPEC.equals(provisioner.getSpec())) {
    try {
      sshKeyInfo=generateSSHKey(programRunId);
    }
 catch (    Exception e) {
      LOG.error("String_Node_Str",programRunId,name,e);
      provisionerNotifier.deprovisioning(programRunId);
      return new NoOpProvisioningTask(programRunId);
    }
  }
  Map<String,String> properties=SystemArguments.getProfileProperties(args);
  ProvisionerContext context=new DefaultProvisionerContext(programRunId,properties,createSSHContext(sshKeyInfo));
  ClusterOp clusterOp=new ClusterOp(ClusterOp.Type.PROVISION,ClusterOp.Status.REQUESTING_CREATE);
  ClusterInfo clusterInfo=new ClusterInfo(programRunId,provisionRequest.getProgramDescriptor(),properties,name,provisionRequest.getUser(),clusterOp,sshKeyInfo,null);
  ProvisionerDataset provisionerDataset=ProvisionerDataset.get(datasetContext,datasetFramework);
  provisionerDataset.putClusterInfo(clusterInfo);
  return new ProvisionTask(provisionRequest,provisioner,context,provisionerNotifier,transactional,datasetFramework,sshKeyInfo);
}