Program: 28188
Project: 28188
Buggy source:
/** 
 * Deploys the application (with optional deployment plan) to the specified targets with the indicated options.
 * @param targets targets to which to deploy the application
 * @param source the app
 * @param deploymentPlan the deployment plan (null if not specified)
 * @param deploymentOptions options to be applied to the deployment
 * @return DFProgressObject the caller can use to monitor progress and query status
 */
public DFProgressObject deploy(Target[] targets,URI source,URI deploymentPlan,Map deploymentOptions){
  ensureConnected();
  targets=prepareTargets(targets);
  ProgressObjectImpl po=new ProgressObjectImpl(targets);
  List<TargetModuleIDImpl> targetModuleIDList=new ArrayList<TargetModuleIDImpl>();
  if (source == null) {
    po.setupForAbnormalExit(localStrings.getLocalString("String_Node_Str","String_Node_Str"),(TargetImpl)targets[0]);
    return po;
  }
  File tmpFile=new File(source.getSchemeSpecificPart());
  if (!tmpFile.exists()) {
    po.setupForAbnormalExit(localStrings.getLocalString("String_Node_Str","String_Node_Str"),domain);
    return po;
  }
  if (!tmpFile.canRead()) {
    po.setupForAbnormalExit(localStrings.getLocalString("String_Node_Str","String_Node_Str"),domain);
    return po;
  }
  try {
    if (deploymentPlan != null) {
      File dp=new File(deploymentPlan.getSchemeSpecificPart());
      if (!dp.exists()) {
        po.setupForAbnormalExit(localStrings.getLocalString("String_Node_Str","String_Node_Str"),domain);
        return po;
      }
      if (!dp.canRead()) {
        po.setupForAbnormalExit(localStrings.getLocalString("String_Node_Str","String_Node_Str"),domain);
        return po;
      }
      deploymentOptions.put(DFDeploymentProperties.DEPLOYMENT_PLAN,dp.getAbsolutePath());
    }
    boolean isRedeploy=Boolean.valueOf((String)deploymentOptions.remove(DFDeploymentProperties.REDEPLOY));
    if (isRedeploy) {
      String appName=(String)deploymentOptions.get(DFDeploymentProperties.NAME);
      if (!isTargetsMatched(appName,targets)) {
        po.setupForAbnormalExit(localStrings.getLocalString("String_Node_Str","String_Node_Str",appName,"String_Node_Str"),domain);
      }
      String enabledAttr=getAppRefEnabledAttr(targets[0].getName(),appName);
      deploymentOptions.put(DFDeploymentProperties.ENABLED,enabledAttr);
    }
    Target[] origTargets=targets;
    if (isRedeploy && targets.length > 1) {
      targets=createTargets(new String[]{"String_Node_Str"});
    }
    deploymentOptions.put(DFDeploymentProperties.TARGET,targets[0].getName());
    DFCommandRunner commandRunner=getDFCommandRunner("String_Node_Str",deploymentOptions,new String[]{tmpFile.getAbsolutePath()});
    DFDeploymentStatus ds=commandRunner.run();
    DFDeploymentStatus mainStatus=ds.getMainStatus();
    String moduleID;
    if (!po.checkStatusAndAddStage((TargetImpl)targets[0],localStrings.getLocalString("String_Node_Str","String_Node_Str",targets[0].getName()),mainStatus)) {
      return po;
    }
 else {
      moduleID=mainStatus.getProperty(DFDeploymentProperties.NAME);
      if (moduleID == null) {
        moduleID=(String)deploymentOptions.get(DFDeploymentProperties.NAME);
      }
      po.setModuleID(moduleID);
    }
    Map createAppRefOptions=new HashMap();
    if (deploymentOptions.get(DFDeploymentProperties.ENABLED) != null) {
      createAppRefOptions.put(DFDeploymentProperties.ENABLED,deploymentOptions.get(DFDeploymentProperties.ENABLED));
    }
    if (deploymentOptions.get(DFDeploymentProperties.VIRTUAL_SERVERS) != null) {
      createAppRefOptions.put(DFDeploymentProperties.VIRTUAL_SERVERS,deploymentOptions.get(DFDeploymentProperties.VIRTUAL_SERVERS));
    }
    for (int i=1; i < targets.length; i++) {
      createAppRefOptions.put(DFDeploymentProperties.TARGET,targets[i].getName());
      DFCommandRunner commandRunner2=getDFCommandRunner("String_Node_Str",createAppRefOptions,new String[]{moduleID});
      DFDeploymentStatus ds2=commandRunner2.run();
      DFDeploymentStatus mainStatus2=ds2.getMainStatus();
      if (!po.checkStatusAndAddStage((TargetImpl)targets[i],"String_Node_Str",mainStatus2)) {
        return po;
      }
    }
    for (int i=0; i < origTargets.length; i++) {
      TargetModuleIDImpl targetModuleID=new TargetModuleIDImpl((TargetImpl)origTargets[i],moduleID);
      targetModuleIDList.add(targetModuleID);
    }
    TargetModuleIDImpl[] targetModuleIDs=new TargetModuleIDImpl[targetModuleIDList.size()];
    targetModuleIDs=(TargetModuleIDImpl[])targetModuleIDList.toArray(targetModuleIDs);
    po.setupForNormalExit(localStrings.getLocalString("String_Node_Str","String_Node_Str",moduleID),(TargetImpl)targets[0],targetModuleIDs);
    return po;
  }
 catch (  Throwable ioex) {
    po.setupForAbnormalExit(localStrings.getLocalString("String_Node_Str","String_Node_Str",ioex.toString()),(TargetImpl)targets[0]);
    return po;
  }
}

Fixed version (ground truth):
/** 
 * Deploys the application (with optional deployment plan) to the specified targets with the indicated options.
 * @param targets targets to which to deploy the application
 * @param source the app
 * @param deploymentPlan the deployment plan (null if not specified)
 * @param deploymentOptions options to be applied to the deployment
 * @return DFProgressObject the caller can use to monitor progress and query status
 */
public DFProgressObject deploy(Target[] targets,URI source,URI deploymentPlan,Map deploymentOptions){
  ensureConnected();
  targets=prepareTargets(targets);
  ProgressObjectImpl po=new ProgressObjectImpl(targets);
  if (deploymentOptions.get(DFDeploymentProperties.DEFAULT_REDEPLOY) == "String_Node_Str")   po.setCommand(CommandType.REDEPLOY,null);
 else   po.setCommand(CommandType.DISTRIBUTE,null);
  List<TargetModuleIDImpl> targetModuleIDList=new ArrayList<TargetModuleIDImpl>();
  if (source == null) {
    po.setupForAbnormalExit(localStrings.getLocalString("String_Node_Str","String_Node_Str"),(TargetImpl)targets[0]);
    return po;
  }
  File tmpFile=new File(source.getSchemeSpecificPart());
  if (!tmpFile.exists()) {
    po.setupForAbnormalExit(localStrings.getLocalString("String_Node_Str","String_Node_Str"),domain);
    return po;
  }
  if (!tmpFile.canRead()) {
    po.setupForAbnormalExit(localStrings.getLocalString("String_Node_Str","String_Node_Str"),domain);
    return po;
  }
  try {
    if (deploymentPlan != null) {
      File dp=new File(deploymentPlan.getSchemeSpecificPart());
      if (!dp.exists()) {
        po.setupForAbnormalExit(localStrings.getLocalString("String_Node_Str","String_Node_Str"),domain);
        return po;
      }
      if (!dp.canRead()) {
        po.setupForAbnormalExit(localStrings.getLocalString("String_Node_Str","String_Node_Str"),domain);
        return po;
      }
      deploymentOptions.put(DFDeploymentProperties.DEPLOYMENT_PLAN,dp.getAbsolutePath());
    }
    boolean isRedeploy=Boolean.valueOf((String)deploymentOptions.remove(DFDeploymentProperties.REDEPLOY));
    if (isRedeploy) {
      String appName=(String)deploymentOptions.get(DFDeploymentProperties.NAME);
      if (!isTargetsMatched(appName,targets)) {
        po.setupForAbnormalExit(localStrings.getLocalString("String_Node_Str","String_Node_Str",appName,"String_Node_Str"),domain);
      }
      String enabledAttr=getAppRefEnabledAttr(targets[0].getName(),appName);
      deploymentOptions.put(DFDeploymentProperties.ENABLED,enabledAttr);
    }
    Target[] origTargets=targets;
    if (isRedeploy && targets.length > 1) {
      targets=createTargets(new String[]{"String_Node_Str"});
    }
    deploymentOptions.put(DFDeploymentProperties.TARGET,targets[0].getName());
    DFCommandRunner commandRunner=getDFCommandRunner("String_Node_Str",deploymentOptions,new String[]{tmpFile.getAbsolutePath()});
    DFDeploymentStatus ds=commandRunner.run();
    DFDeploymentStatus mainStatus=ds.getMainStatus();
    String moduleID;
    if (!po.checkStatusAndAddStage((TargetImpl)targets[0],localStrings.getLocalString("String_Node_Str","String_Node_Str",targets[0].getName()),mainStatus)) {
      return po;
    }
 else {
      moduleID=mainStatus.getProperty(DFDeploymentProperties.NAME);
      if (moduleID == null) {
        moduleID=(String)deploymentOptions.get(DFDeploymentProperties.NAME);
      }
      po.setModuleID(moduleID);
    }
    Map createAppRefOptions=new HashMap();
    if (deploymentOptions.get(DFDeploymentProperties.ENABLED) != null) {
      createAppRefOptions.put(DFDeploymentProperties.ENABLED,deploymentOptions.get(DFDeploymentProperties.ENABLED));
    }
    if (deploymentOptions.get(DFDeploymentProperties.VIRTUAL_SERVERS) != null) {
      createAppRefOptions.put(DFDeploymentProperties.VIRTUAL_SERVERS,deploymentOptions.get(DFDeploymentProperties.VIRTUAL_SERVERS));
    }
    for (int i=1; i < targets.length; i++) {
      createAppRefOptions.put(DFDeploymentProperties.TARGET,targets[i].getName());
      DFCommandRunner commandRunner2=getDFCommandRunner("String_Node_Str",createAppRefOptions,new String[]{moduleID});
      DFDeploymentStatus ds2=commandRunner2.run();
      DFDeploymentStatus mainStatus2=ds2.getMainStatus();
      if (!po.checkStatusAndAddStage((TargetImpl)targets[i],"String_Node_Str",mainStatus2)) {
        return po;
      }
    }
    for (int i=0; i < origTargets.length; i++) {
      TargetModuleIDImpl targetModuleID=new TargetModuleIDImpl((TargetImpl)origTargets[i],moduleID);
      targetModuleIDList.add(targetModuleID);
    }
    TargetModuleIDImpl[] targetModuleIDs=new TargetModuleIDImpl[targetModuleIDList.size()];
    targetModuleIDs=(TargetModuleIDImpl[])targetModuleIDList.toArray(targetModuleIDs);
    po.setupForNormalExit(localStrings.getLocalString("String_Node_Str","String_Node_Str",moduleID),(TargetImpl)targets[0],targetModuleIDs);
    return po;
  }
 catch (  Throwable ioex) {
    po.setupForAbnormalExit(localStrings.getLocalString("String_Node_Str","String_Node_Str",ioex.toString()),(TargetImpl)targets[0]);
    return po;
  }
}