Program: 90165
Project: 90165
Buggy source:
/** 
 * Set/initialize environment variables for this job.
 * @param ji2 job info object for this job
 * @return a map containing environment variables for this job
 * @throws CloudServiceException if there is any error in initialization
 */
@Transactional(readOnly=true) protected Map<String,String> initEnv(Job ji2) throws CloudServiceException {
  LOG.info("String_Node_Str");
  Map<String,String> hEnv=new HashMap<String,String>();
  if ((ji2.getFileDependencies() != null) && (!ji2.getFileDependencies().isEmpty())) {
    hEnv.put("String_Node_Str",ji2.getFileDependencies());
  }
  Set<String> clusterConfigs=this.cluster.getConfigs();
  hEnv.put("String_Node_Str",convertCollectionToCSV(clusterConfigs));
  Command command=null;
  Application application=null;
  boolean done=false;
  if ((ji2.getCommandId() != null) && (!(ji2.getCommandId().isEmpty()))) {
    String cmdId=ji2.getCommandId();
    command=this.em.find(Command.class,cmdId);
    for (    final Application ace : command.getApplications()) {
      if ((ji2.getApplicationId() != null) && ((!ji2.getApplicationId().isEmpty()))) {
        if (ace.getId().equals(ji2.getApplicationId())) {
          application=ace;
          break;
        }
      }
 else       if ((ji2.getApplicationName() != null) && ((!ji2.getApplicationName().isEmpty()))) {
        if (ace.getName().equals(ji2.getApplicationName())) {
          application=ace;
          break;
        }
      }
 else {
        application=ace;
        break;
      }
    }
  }
 else   if ((ji2.getCommandName() != null) && (!(ji2.getCommandName().isEmpty()))) {
    for (    final Command cce : cluster.getCommands()) {
      if (cce.getName().equals(ji2.getCommandName())) {
        for (        final Application ace : cce.getApplications()) {
          if ((ji2.getApplicationId() != null) && ((!ji2.getApplicationId().isEmpty()))) {
            if (ace.getId().equals(ji2.getApplicationId())) {
              command=cce;
              application=ace;
              done=true;
              break;
            }
          }
 else           if ((ji2.getApplicationName() != null) && ((!ji2.getApplicationName().isEmpty()))) {
            if (ace.getName().equals(ji2.getApplicationName())) {
              command=cce;
              application=ace;
              done=true;
              break;
            }
          }
 else {
            command=cce;
            application=ace;
            done=true;
            break;
          }
        }
        if (done) {
          break;
        }
      }
    }
  }
  if (command == null) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new CloudServiceException(HttpURLConnection.HTTP_INTERNAL_ERROR,msg);
  }
  ji2.setCommandId(command.getId());
  ji2.setCommandName(command.getName());
  if (application != null) {
    ji2.setApplicationId(application.getId());
    ji2.setApplicationName(application.getName());
    if ((application.getConfigs() != null) && (!application.getConfigs().isEmpty())) {
      hEnv.put("String_Node_Str",convertCollectionToCSV(application.getConfigs()));
    }
    if ((application.getJars() != null) && (!application.getJars().isEmpty())) {
      hEnv.put("String_Node_Str",convertCollectionToCSV(application.getJars()));
    }
    if ((application.getEnvPropFile() != null) && (!application.getEnvPropFile().isEmpty())) {
      hEnv.put("String_Node_Str",application.getEnvPropFile());
    }
  }
  if ((command.getConfigs() != null) && (!command.getConfigs().isEmpty())) {
    hEnv.put("String_Node_Str",convertCollectionToCSV(command.getConfigs()));
  }
  this.executable=command.getExecutable();
  ji2.setExecutionClusterName(cluster.getName());
  ji2.setExecutionClusterId(cluster.getId());
  if ((command.getEnvPropFile() != null) && (!command.getEnvPropFile().isEmpty())) {
    hEnv.put("String_Node_Str",command.getEnvPropFile());
  }
  if ((ji2.getEnvPropFile() != null) && (!ji2.getEnvPropFile().isEmpty())) {
    hEnv.put("String_Node_Str",ji2.getEnvPropFile());
  }
  hEnv.put("String_Node_Str",ji2.getUser());
  hEnv.put("String_Node_Str",ji2.getUser());
  String groupName=HADOOP_GROUP_NAME;
  if (ji2.getGroup() != null) {
    groupName=ji2.getGroup();
    hEnv.put("String_Node_Str",groupName);
  }
  hEnv.put("String_Node_Str",groupName);
  String javaHome=ConfigurationManager.getConfigInstance().getString("String_Node_Str");
  if ((javaHome != null) && (!javaHome.isEmpty())) {
    hEnv.put("String_Node_Str",javaHome);
  }
  String genieHome=ConfigurationManager.getConfigInstance().getString("String_Node_Str");
  if ((genieHome == null) || genieHome.isEmpty()) {
    String msg="String_Node_Str";
    LOG.error(msg);
    throw new CloudServiceException(HttpURLConnection.HTTP_INTERNAL_ERROR,msg);
  }
  hEnv.put("String_Node_Str",genieHome);
  String hadoopHome;
  if (cluster.getVersion() != null) {
    String hadoopVersion=cluster.getVersion();
    LOG.debug("String_Node_Str" + hadoopVersion);
    hadoopHome=ConfigurationManager.getConfigInstance().getString("String_Node_Str" + hadoopVersion + "String_Node_Str");
    if (hadoopHome == null) {
      hadoopVersion=StringUtil.trimVersion(hadoopVersion);
      hadoopHome=ConfigurationManager.getConfigInstance().getString("String_Node_Str" + hadoopVersion + "String_Node_Str");
    }
    if ((hadoopHome == null) || (!new File(hadoopHome).exists())) {
      String msg="String_Node_Str" + hadoopVersion;
      LOG.error(msg);
      throw new CloudServiceException(HttpURLConnection.HTTP_INTERNAL_ERROR,msg);
    }
    LOG.info("String_Node_Str" + hadoopHome);
    hEnv.put("String_Node_Str",hadoopHome);
  }
 else {
    hadoopHome=ConfigurationManager.getConfigInstance().getString("String_Node_Str");
    if ((hadoopHome == null) || (!new File(hadoopHome).exists())) {
      String msg="String_Node_Str";
      LOG.error(msg);
      throw new CloudServiceException(HttpURLConnection.HTTP_INTERNAL_ERROR,msg);
    }
    hEnv.put("String_Node_Str",hadoopHome);
  }
  hEnv.put("String_Node_Str",ConfigurationManager.getConfigInstance().getString("String_Node_Str","String_Node_Str"));
  String cpOpts;
  cpOpts=ConfigurationManager.getConfigInstance().getString("String_Node_Str","String_Node_Str");
  String copyCommand=hadoopHome + "String_Node_Str" + cpOpts+ "String_Node_Str";
  hEnv.put("String_Node_Str",copyCommand);
  String mkdirCommand=hadoopHome + "String_Node_Str" + cpOpts+ "String_Node_Str";
  hEnv.put("String_Node_Str",mkdirCommand);
  String baseUserWorkingDir=ConfigurationManager.getConfigInstance().getString("String_Node_Str");
  if ((baseUserWorkingDir == null) || (baseUserWorkingDir.isEmpty())) {
    String msg="String_Node_Str";
    LOG.error(msg);
    throw new CloudServiceException(HttpURLConnection.HTTP_INTERNAL_ERROR,msg);
  }
 else {
    hEnv.put("String_Node_Str",baseUserWorkingDir);
  }
  if (!ji2.isDisableLogArchival()) {
    String s3ArchiveLocation=ConfigurationManager.getConfigInstance().getString("String_Node_Str");
    if ((s3ArchiveLocation != null) && (!s3ArchiveLocation.isEmpty())) {
      hEnv.put("String_Node_Str",s3ArchiveLocation);
    }
  }
  hEnv.put("String_Node_Str",genieJobIDProp + "String_Node_Str" + netflixEnvProp+ "String_Node_Str"+ lipstickUuidProp);
  return hEnv;
}

Fixed version (ground truth):
/** 
 * Set/initialize environment variables for this job.
 * @param ji2 job info object for this job
 * @return a map containing environment variables for this job
 * @throws CloudServiceException if there is any error in initialization
 */
@Transactional(readOnly=true) protected Map<String,String> initEnv(Job ji2) throws CloudServiceException {
  LOG.info("String_Node_Str");
  Map<String,String> hEnv=new HashMap<String,String>();
  if ((ji2.getFileDependencies() != null) && (!ji2.getFileDependencies().isEmpty())) {
    hEnv.put("String_Node_Str",ji2.getFileDependencies());
  }
  Set<String> clusterConfigs=this.cluster.getConfigs();
  hEnv.put("String_Node_Str",convertCollectionToCSV(clusterConfigs));
  Command command=null;
  Application application=null;
  boolean done=false;
  if ((ji2.getCommandId() != null) && (!(ji2.getCommandId().isEmpty()))) {
    String cmdId=ji2.getCommandId();
    command=this.em.find(Command.class,cmdId);
    for (    final Application ace : command.getApplications()) {
      if ((ji2.getApplicationId() != null) && ((!ji2.getApplicationId().isEmpty()))) {
        if (ace.getId().equals(ji2.getApplicationId())) {
          application=ace;
          break;
        }
      }
 else       if ((ji2.getApplicationName() != null) && ((!ji2.getApplicationName().isEmpty()))) {
        if (ace.getName().equals(ji2.getApplicationName())) {
          application=ace;
          break;
        }
      }
 else {
        application=ace;
        break;
      }
    }
  }
 else   if ((ji2.getCommandName() != null) && (!(ji2.getCommandName().isEmpty()))) {
    for (    final Command cce : cluster.getCommands()) {
      if (cce.getName().equals(ji2.getCommandName())) {
        for (        final Application ace : cce.getApplications()) {
          if ((ji2.getApplicationId() != null) && ((!ji2.getApplicationId().isEmpty()))) {
            if (ace.getId().equals(ji2.getApplicationId())) {
              command=cce;
              application=ace;
              done=true;
              break;
            }
          }
 else           if ((ji2.getApplicationName() != null) && ((!ji2.getApplicationName().isEmpty()))) {
            if (ace.getName().equals(ji2.getApplicationName())) {
              command=cce;
              application=ace;
              done=true;
              break;
            }
          }
 else {
            command=cce;
            application=ace;
            done=true;
            break;
          }
        }
        if (done) {
          break;
        }
      }
    }
  }
  if (command == null) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new CloudServiceException(HttpURLConnection.HTTP_INTERNAL_ERROR,msg);
  }
  ji2.setCommandId(command.getId());
  ji2.setCommandName(command.getName());
  if (application != null) {
    ji2.setApplicationId(application.getId());
    ji2.setApplicationName(application.getName());
    if ((application.getConfigs() != null) && (!application.getConfigs().isEmpty())) {
      hEnv.put("String_Node_Str",convertCollectionToCSV(application.getConfigs()));
    }
    if ((application.getJars() != null) && (!application.getJars().isEmpty())) {
      hEnv.put("String_Node_Str",convertCollectionToCSV(application.getJars()));
    }
    if ((application.getEnvPropFile() != null) && (!application.getEnvPropFile().isEmpty())) {
      hEnv.put("String_Node_Str",application.getEnvPropFile());
    }
  }
  if ((command.getConfigs() != null) && (!command.getConfigs().isEmpty())) {
    hEnv.put("String_Node_Str",convertCollectionToCSV(command.getConfigs()));
  }
  this.executable=command.getExecutable();
  ji2.setExecutionClusterName(cluster.getName());
  ji2.setExecutionClusterId(cluster.getId());
  if ((command.getEnvPropFile() != null) && (!command.getEnvPropFile().isEmpty())) {
    hEnv.put("String_Node_Str",command.getEnvPropFile());
  }
  if ((ji2.getEnvPropFile() != null) && (!ji2.getEnvPropFile().isEmpty())) {
    hEnv.put("String_Node_Str",ji2.getEnvPropFile());
  }
  hEnv.put("String_Node_Str",ji2.getUser());
  hEnv.put("String_Node_Str",ji2.getUser());
  String groupName=HADOOP_GROUP_NAME;
  if (ji2.getGroup() != null) {
    groupName=ji2.getGroup();
    hEnv.put("String_Node_Str",groupName);
  }
  hEnv.put("String_Node_Str",groupName);
  String javaHome=ConfigurationManager.getConfigInstance().getString("String_Node_Str");
  if ((javaHome != null) && (!javaHome.isEmpty())) {
    hEnv.put("String_Node_Str",javaHome);
  }
  String genieHome=ConfigurationManager.getConfigInstance().getString("String_Node_Str");
  if ((genieHome == null) || genieHome.isEmpty()) {
    String msg="String_Node_Str";
    LOG.error(msg);
    throw new CloudServiceException(HttpURLConnection.HTTP_INTERNAL_ERROR,msg);
  }
  hEnv.put("String_Node_Str",genieHome);
  String hadoopHome;
  if (this.cluster.getVersion() != null) {
    String hadoopVersion=cluster.getVersion();
    LOG.debug("String_Node_Str" + hadoopVersion);
    hadoopHome=ConfigurationManager.getConfigInstance().getString("String_Node_Str" + hadoopVersion + "String_Node_Str");
    if (hadoopHome == null) {
      hadoopVersion=StringUtil.trimVersion(hadoopVersion);
      hadoopHome=ConfigurationManager.getConfigInstance().getString("String_Node_Str" + hadoopVersion + "String_Node_Str");
    }
    if ((hadoopHome == null) || (!new File(hadoopHome).exists())) {
      String msg="String_Node_Str" + hadoopVersion;
      LOG.error(msg);
      throw new CloudServiceException(HttpURLConnection.HTTP_INTERNAL_ERROR,msg);
    }
    LOG.info("String_Node_Str" + hadoopHome);
    hEnv.put("String_Node_Str",hadoopHome);
  }
 else {
    hadoopHome=ConfigurationManager.getConfigInstance().getString("String_Node_Str");
    if ((hadoopHome == null) || (!new File(hadoopHome).exists())) {
      String msg="String_Node_Str";
      LOG.error(msg);
      throw new CloudServiceException(HttpURLConnection.HTTP_INTERNAL_ERROR,msg);
    }
    hEnv.put("String_Node_Str",hadoopHome);
  }
  hEnv.put("String_Node_Str",ConfigurationManager.getConfigInstance().getString("String_Node_Str","String_Node_Str"));
  String cpOpts;
  cpOpts=ConfigurationManager.getConfigInstance().getString("String_Node_Str","String_Node_Str");
  String copyCommand=hadoopHome + "String_Node_Str" + cpOpts+ "String_Node_Str";
  hEnv.put("String_Node_Str",copyCommand);
  String mkdirCommand=hadoopHome + "String_Node_Str" + cpOpts+ "String_Node_Str";
  hEnv.put("String_Node_Str",mkdirCommand);
  String baseUserWorkingDir=ConfigurationManager.getConfigInstance().getString("String_Node_Str");
  if ((baseUserWorkingDir == null) || (baseUserWorkingDir.isEmpty())) {
    String msg="String_Node_Str";
    LOG.error(msg);
    throw new CloudServiceException(HttpURLConnection.HTTP_INTERNAL_ERROR,msg);
  }
 else {
    hEnv.put("String_Node_Str",baseUserWorkingDir);
  }
  if (!ji2.isDisableLogArchival()) {
    String s3ArchiveLocation=ConfigurationManager.getConfigInstance().getString("String_Node_Str");
    if ((s3ArchiveLocation != null) && (!s3ArchiveLocation.isEmpty())) {
      hEnv.put("String_Node_Str",s3ArchiveLocation);
    }
  }
  hEnv.put("String_Node_Str",genieJobIDProp + "String_Node_Str" + netflixEnvProp+ "String_Node_Str"+ lipstickUuidProp);
  return hEnv;
}