Program: 28668
Project: 28668
Buggy source:
public String process(AdminCommandContext context) throws Exception {
  LoadbalancerReader lbr=null;
  if (lbName != null && lbConfigName == null && target == null) {
    LoadBalancer lb=LbConfigHelper.getLoadBalancer(domain,lbName);
    lbr=LbConfigHelper.getLbReader(domain,appRegistry,lb.getLbConfigName());
  }
 else   if (lbConfigName != null && lbName == null && target == null) {
    lbr=LbConfigHelper.getLbReader(domain,appRegistry,lbConfigName);
  }
 else   if (target != null && lbName == null && lbConfigName == null) {
    Set<String> clusters=new HashSet<String>();
    clusters.addAll(target);
    lbr=new LoadbalancerReaderImpl(domain,appRegistry,clusters,properties);
  }
 else {
    String msg=LbLogUtil.getStringManager().getString("String_Node_Str");
    throw new Exception(msg);
  }
  if (fileName == null) {
    String configName=lbr.getName();
    if (configName != null) {
      fileName=DEFAULT_LB_XML_FILE_NAME + "String_Node_Str" + configName;
    }
 else {
      fileName=DEFAULT_LB_XML_FILE_NAME;
    }
  }
  File lbConfigFile=new File(fileName);
  if (!lbConfigFile.isAbsolute() && !retrieveFile) {
    File loadbalancerDir=new File(env.getInstanceRoot(),"String_Node_Str");
    if (!loadbalancerDir.exists()) {
      loadbalancerDir.mkdir();
    }
    lbConfigFile=new File(loadbalancerDir,fileName);
  }
  if (type != null) {
    if (!(type.equals("String_Node_Str") || type.equals("String_Node_Str"))) {
      String msg=LbLogUtil.getStringManager().getString("String_Node_Str");
      throw new Exception(msg);
    }
    File tmpLbWorkerFile=null;
    if (retrieveFile) {
      if (type.equals("String_Node_Str")) {
        tmpLbWorkerFile=File.createTempFile("String_Node_Str","String_Node_Str");
      }
 else {
        tmpLbWorkerFile=File.createTempFile("String_Node_Str","String_Node_Str");
      }
      tmpLbWorkerFile.deleteOnExit();
    }
 else {
      if (lbConfigFile.exists()) {
        String msg=LbLogUtil.getStringManager().getString("String_Node_Str",lbConfigFile.getPath());
        throw new Exception(msg);
      }
      if (!(lbConfigFile.getParentFile().exists())) {
        String msg=LbLogUtil.getStringManager().getString("String_Node_Str",lbConfigFile.getParent());
        throw new Exception(msg);
      }
      tmpLbWorkerFile=lbConfigFile;
    }
    FileOutputStream fo=null;
    try {
      fo=new FileOutputStream(tmpLbWorkerFile);
      if (type.equals("String_Node_Str")) {
        LbConfigHelper.exportWorkerProperties(lbr,fo);
      }
 else {
        LbConfigHelper.exportOtdProperties(lbr,fo);
      }
      if (retrieveFile) {
        retrieveLbConfig(context,lbConfigFile,tmpLbWorkerFile);
      }
      LbConfig lbConfig=lbr.getLbConfig();
      if (lbConfig != null) {
        lbConfig.setLastExported();
      }
      String msg=LbLogUtil.getStringManager().getString("String_Node_Str",lbConfigFile.toString());
      return msg;
    }
  finally {
      if (fo != null) {
        fo.close();
        fo=null;
      }
    }
  }
 else {
    File tmpLbXmlFile=null;
    if (retrieveFile) {
      tmpLbXmlFile=File.createTempFile("String_Node_Str","String_Node_Str");
      tmpLbXmlFile.deleteOnExit();
    }
 else {
      if (lbConfigFile.exists()) {
        String msg=LbLogUtil.getStringManager().getString("String_Node_Str",lbConfigFile.getPath());
        throw new Exception(msg);
      }
      if (!(lbConfigFile.getParentFile().exists())) {
        String msg=LbLogUtil.getStringManager().getString("String_Node_Str",lbConfigFile.getParent());
        throw new Exception(msg);
      }
      tmpLbXmlFile=lbConfigFile;
    }
    FileOutputStream fo=null;
    try {
      fo=new FileOutputStream(tmpLbXmlFile);
      LbConfigHelper.exportXml(lbr,fo);
      if (retrieveFile) {
        retrieveLbConfig(context,lbConfigFile,tmpLbXmlFile);
      }
      LbConfig lbConfig=lbr.getLbConfig();
      if (lbConfig != null) {
        lbConfig.setLastExported();
      }
      String msg=LbLogUtil.getStringManager().getString("String_Node_Str",lbConfigFile.toString());
      return msg;
    }
  finally {
      if (fo != null) {
        fo.close();
        fo=null;
      }
    }
  }
}

Fixed version (ground truth):
public String process(AdminCommandContext context) throws Exception {
  LoadbalancerReader lbr=null;
  if (lbName != null && lbConfigName == null && target == null) {
    LoadBalancer lb=LbConfigHelper.getLoadBalancer(domain,lbName);
    lbr=LbConfigHelper.getLbReader(domain,appRegistry,lb.getLbConfigName());
  }
 else   if (lbConfigName != null && lbName == null && target == null) {
    lbr=LbConfigHelper.getLbReader(domain,appRegistry,lbConfigName);
  }
 else   if (target != null && lbName == null && lbConfigName == null) {
    Set<String> clusters=new HashSet<String>();
    clusters.addAll(target);
    lbr=new LoadbalancerReaderImpl(domain,appRegistry,clusters,properties);
  }
 else {
    String msg=LbLogUtil.getStringManager().getString("String_Node_Str");
    throw new Exception(msg);
  }
  if (fileName == null) {
    String configName=lbr.getName();
    if (configName != null) {
      fileName=DEFAULT_LB_XML_FILE_NAME + "String_Node_Str" + configName;
    }
 else {
      fileName=DEFAULT_LB_XML_FILE_NAME;
    }
  }
  File lbConfigFile=new File(fileName);
  if (!lbConfigFile.isAbsolute() && !retrieveFile) {
    File loadbalancerDir=new File(env.getInstanceRoot(),"String_Node_Str");
    if (!loadbalancerDir.exists()) {
      boolean isMkdirSuccess=loadbalancerDir.mkdir();
      if (!isMkdirSuccess) {
        String msg=LbLogUtil.getStringManager().getString("String_Node_Str");
        throw new Exception(msg);
      }
    }
    lbConfigFile=new File(loadbalancerDir,fileName);
  }
  File tmpLbXmlFile=null;
  if (retrieveFile) {
    tmpLbXmlFile=File.createTempFile("String_Node_Str","String_Node_Str");
    tmpLbXmlFile.deleteOnExit();
  }
 else {
    if (lbConfigFile.exists()) {
      String msg=LbLogUtil.getStringManager().getString("String_Node_Str",lbConfigFile.getPath());
      throw new Exception(msg);
    }
    if (!(lbConfigFile.getParentFile().exists())) {
      String msg=LbLogUtil.getStringManager().getString("String_Node_Str",lbConfigFile.getParent());
      throw new Exception(msg);
    }
    tmpLbXmlFile=lbConfigFile;
  }
  FileOutputStream fo=null;
  try {
    fo=new FileOutputStream(tmpLbXmlFile);
    LbConfigHelper.exportXml(lbr,fo);
    if (retrieveFile) {
      retrieveLbConfig(context,lbConfigFile,tmpLbXmlFile);
    }
    LbConfig lbConfig=lbr.getLbConfig();
    if (lbConfig != null) {
      lbConfig.setLastExported();
    }
    String msg=LbLogUtil.getStringManager().getString("String_Node_Str",lbConfigFile.toString());
    return msg;
  }
  finally {
    if (fo != null) {
      fo.close();
      fo=null;
    }
  }
}