nus-yam/ex-repair huggingface dataset:
Program: 90129
Project: 90129
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void init(final Job job,final Cluster cluster) throws GenieException {
  if (job == null) {
    throw new GeniePreconditionException("String_Node_Str");
  }
  if (cluster == null) {
    throw new GeniePreconditionException("String_Node_Str");
  }
  this.jobMonitor.setJobManager(this);
  this.job=job;
  this.cluster=cluster;
  this.jobService.setClusterInfoForJob(this.job.getId(),this.cluster.getId(),this.cluster.getName());
  Command command=null;
  for (  final Command cmd : this.cluster.getCommands()) {
    if (cmd.getTags().containsAll(this.job.getCommandCriteria())) {
      command=cmd;
      break;
    }
  }
  if (command == null) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GeniePreconditionException(msg);
  }
  this.jobService.setCommandInfoForJob(this.job.getId(),command.getId(),command.getName());
  final Application application=command.getApplication();
  if (application != null) {
    this.jobService.setApplicationInfoForJob(this.job.getId(),application.getId(),application.getName());
  }
  this.job=this.jobService.getJob(this.job.getId());
  this.initCalled=true;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void init(final Job job,final Cluster cluster) throws GenieException {
  if (job == null) {
    throw new GeniePreconditionException("String_Node_Str");
  }
  if (cluster == null) {
    throw new GeniePreconditionException("String_Node_Str");
  }
  this.jobMonitor.setJobManager(this);
  this.job=job;
  this.cluster=cluster;
  this.attachments=this.job.getAttachments();
  this.jobService.setClusterInfoForJob(this.job.getId(),this.cluster.getId(),this.cluster.getName());
  Command command=null;
  for (  final Command cmd : this.cluster.getCommands()) {
    if (cmd.getTags().containsAll(this.job.getCommandCriteria())) {
      command=cmd;
      break;
    }
  }
  if (command == null) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GeniePreconditionException(msg);
  }
  this.jobService.setCommandInfoForJob(this.job.getId(),command.getId(),command.getName());
  final Application application=command.getApplication();
  if (application != null) {
    this.jobService.setApplicationInfoForJob(this.job.getId(),application.getId(),application.getName());
  }
  this.job=this.jobService.getJob(this.job.getId());
  this.initCalled=true;
}
Program: 90130
Project: 90130
Buggy source:
/** 
 * Copy over any attachments for the job which exist.
 * @throws GenieException
 */
private void copyAttachments() throws GenieException {
  if (this.job.getAttachments() != null) {
    for (    final FileAttachment attachment : this.job.getAttachments()) {
      if (attachment.getName() == null || attachment.getName().isEmpty()) {
        final String msg="String_Node_Str";
        LOG.error(msg);
        throw new GeniePreconditionException(msg);
      }
      if (attachment.getData() == null) {
        final String msg="String_Node_Str";
        LOG.error(msg);
        throw new GeniePreconditionException(msg);
      }
      try (final FileOutputStream output=new FileOutputStream(this.jobDir + File.separator + attachment.getName())){
        output.write(attachment.getData());
      }
 catch (      final IOException e) {
        final String msg="String_Node_Str" + attachment.getName();
        LOG.error(msg);
        throw new GenieServerException(msg,e);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Copy over any attachments for the job which exist.
 * @throws GenieException
 */
private void copyAttachments() throws GenieException {
  if (this.attachments != null) {
    for (    final FileAttachment attachment : this.job.getAttachments()) {
      if (attachment.getName() == null || attachment.getName().isEmpty()) {
        final String msg="String_Node_Str";
        LOG.error(msg);
        throw new GeniePreconditionException(msg);
      }
      if (attachment.getData() == null) {
        final String msg="String_Node_Str";
        LOG.error(msg);
        throw new GeniePreconditionException(msg);
      }
      try (final FileOutputStream output=new FileOutputStream(this.jobDir + File.separator + attachment.getName())){
        output.write(attachment.getData());
      }
 catch (      final IOException e) {
        final String msg="String_Node_Str" + attachment.getName();
        LOG.error(msg);
        throw new GenieServerException(msg,e);
      }
    }
  }
}
Program: 90131
Project: 90131
Buggy source:
/** 
 * Test getting number of running jobs on one instance.
 * @throws GenieException if there is any error during this test
 */
@Test @DatabaseSetup("String_Node_Str") public void testNumInstanceJobs() throws GenieException {
  final String hostName=NetUtil.getHostName();
  final List<Job> jobs=this.jobRepo.findAll();
  for (  final Job job : jobs) {
    job.setHostName(hostName);
  }
  this.jobRepo.flush();
  Assert.assertEquals(2,this.manager.getNumInstanceJobs());
  Assert.assertEquals(2,this.manager.getNumInstanceJobs(0L,System.currentTimeMillis()));
  Assert.assertEquals(1,this.manager.getNumInstanceJobs(1404257259000L,1404257260000L));
  Assert.assertEquals(1,this.manager.getNumInstanceJobs(hostName,1404257258000L,1404257259000L));
  Assert.assertEquals(0,this.manager.getNumInstanceJobs(0L,0L));
}

Fixed version (ground truth):
/** 
 * Test getting number of running jobs on one instance.
 * @throws GenieException if there is any error during this test
 */
@Test @DatabaseSetup("String_Node_Str") public void testNumInstanceJobs() throws GenieException {
  final String hostName=NetUtil.getHostName();
  final List<Job> jobs=this.jobRepo.findAll();
  for (  final Job job : jobs) {
    job.setHostName(hostName);
  }
  this.jobRepo.flush();
  final Calendar one=Calendar.getInstance();
  one.clear();
  one.set(2014,Calendar.JULY,1,16,27,38);
  final Calendar two=Calendar.getInstance();
  two.clear();
  two.set(2014,Calendar.JULY,1,16,27,39);
  final Calendar three=Calendar.getInstance();
  three.clear();
  three.set(2014,Calendar.JULY,1,16,27,40);
  Assert.assertEquals(2,this.manager.getNumInstanceJobs());
  Assert.assertEquals(2,this.manager.getNumInstanceJobs(0L,System.currentTimeMillis()));
  Assert.assertEquals(1,this.manager.getNumInstanceJobs(one.getTimeInMillis(),two.getTimeInMillis()));
  Assert.assertEquals(1,this.manager.getNumInstanceJobs(hostName,two.getTimeInMillis(),three.getTimeInMillis()));
  Assert.assertEquals(0,this.manager.getNumInstanceJobs(0L,0L));
}
Program: 90132
Project: 90132
Buggy source:
/** 
 * Test the setter and getter for attachments.
 * @throws GenieException
 */
@Test public void testSetGetAttachments() throws GenieException {
  Assert.assertNull(this.job.getAttachments());
  final FileAttachment attachment=new FileAttachment();
  attachment.setName("String_Node_Str");
  attachment.setData("String_Node_Str".getBytes());
  final Set<FileAttachment> attachments=new HashSet<FileAttachment>();
  attachments.add(attachment);
  this.job.setAttachments(attachments);
  Assert.assertEquals(attachments,this.job.getAttachments());
}

Fixed version (ground truth):
/** 
 * Test the setter and getter for attachments.
 * @throws GenieException
 */
@Test public void testSetGetAttachments() throws GenieException {
  Assert.assertNull(this.job.getAttachments());
  final FileAttachment attachment=new FileAttachment();
  attachment.setName("String_Node_Str");
  attachment.setData("String_Node_Str".getBytes(UTF8_CHARSET));
  final Set<FileAttachment> attachments=new HashSet<FileAttachment>();
  attachments.add(attachment);
  this.job.setAttachments(attachments);
  Assert.assertEquals(attachments,this.job.getAttachments());
}
Program: 90135
Project: 90135
Buggy source:
/** 
 * Wait for job to complete, until the given timeout.
 * @param id           the Genie job ID to wait for completion
 * @param blockTimeout the time to block for (in ms), after which aGenieException will be thrown
 * @param pollTime     the time to sleep between polling for job status
 * @return the jobInfo for the job after completion
 * @throws GenieException       on service errors
 * @throws InterruptedException on timeout/thread errors
 */
public Job waitForCompletion(final String id,final long blockTimeout,final long pollTime) throws GenieException, InterruptedException {
  if (StringUtils.isEmpty(id)) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  final long startTime=System.currentTimeMillis();
  while (true) {
    final Job job=getJob(id);
    if (job.getFinished() != new Date(0)) {
      return job;
    }
    long currTime=System.currentTimeMillis();
    if (currTime - startTime < blockTimeout) {
      Thread.sleep(pollTime);
    }
 else {
      final String msg="String_Node_Str";
      LOG.error(msg);
      throw new InterruptedException(msg);
    }
  }
}

Fixed version (ground truth):
/** 
 * Wait for job to complete, until the given timeout.
 * @param id           the Genie job ID to wait for completion
 * @param blockTimeout the time to block for (in ms), after which aGenieException will be thrown
 * @param pollTime     the time to sleep between polling for job status
 * @return the jobInfo for the job after completion
 * @throws GenieException       on service errors
 * @throws InterruptedException on timeout/thread errors
 */
public Job waitForCompletion(final String id,final long blockTimeout,final long pollTime) throws GenieException, InterruptedException {
  if (StringUtils.isEmpty(id)) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  final long startTime=System.currentTimeMillis();
  while (true) {
    final Job job=getJob(id);
    if (!job.getFinished().equals(new Date(0))) {
      return job;
    }
    long currTime=System.currentTimeMillis();
    if (currTime - startTime < blockTimeout) {
      Thread.sleep(pollTime);
    }
 else {
      final String msg="String_Node_Str";
      LOG.error(msg);
      throw new InterruptedException(msg);
    }
  }
}
Program: 90136
Project: 90136
Buggy source:
/** 
 * Initialize, and launch the job once it has been initialized.
 * @param job the JobInfo object for the job to be launched
 * @throws GenieException
 */
void launch(final Job job) throws GenieException ;

Fixed version (ground truth):
/** 
 * Launch the job.
 * @throws GenieException
 */
void launch() throws GenieException ;
Program: 90137
Project: 90137
Buggy source:
/** 
 * Kill a job using the job information - no need to initialize this job.
 * @param job the JobInfo object for the job to be killed
 * @throws GenieException
 */
void kill(final Job job) throws GenieException ;

Fixed version (ground truth):
/** 
 * Kill a job using the job information - no need to initialize this job.
 * @throws GenieException
 */
void kill() throws GenieException ;
Program: 90138
Project: 90138
Buggy source:
/** 
 * Returns the right job manager for the job type.
 * @param job The job this manager will be managing
 * @return instance of the appropriate job manager
 * @throws GenieException
 */
public JobManager getJobManager(final Job job) throws GenieException {
  LOG.info("String_Node_Str");
  final Cluster cluster=this.clb.selectCluster(this.ccs.getClusters(job));
  final String className=ConfigurationManager.getConfigInstance().getString("String_Node_Str" + cluster.getClusterType() + "String_Node_Str");
  try {
    final Class jobManagerClass=Class.forName(className);
    final Object instance=this.context.getBean(jobManagerClass);
    if (instance instanceof JobManager) {
      final JobManager jobManager=(JobManager)instance;
      jobManager.setCluster(cluster);
      return jobManager;
    }
 else {
      final String msg=className + "String_Node_Str";
      LOG.error(msg);
      throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
    }
  }
 catch (  final ClassNotFoundException e) {
    final String msg="String_Node_Str" + className;
    LOG.error(msg,e);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
catch (  final BeansException e) {
    final String msg="String_Node_Str" + className;
    LOG.error(msg,e);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
}

Fixed version (ground truth):
/** 
 * Returns the right job manager for the job type.
 * @param job The job this manager will be managing
 * @return instance of the appropriate job manager
 * @throws GenieException
 */
public JobManager getJobManager(final Job job) throws GenieException {
  LOG.info("String_Node_Str");
  final Cluster cluster=this.clb.selectCluster(this.ccs.getClusters(job));
  final String className=ConfigurationManager.getConfigInstance().getString("String_Node_Str" + cluster.getClusterType() + "String_Node_Str");
  try {
    final Class jobManagerClass=Class.forName(className);
    final Object instance=this.context.getBean(jobManagerClass);
    if (instance instanceof JobManager) {
      final JobManager jobManager=(JobManager)instance;
      jobManager.init(job,cluster);
      return jobManager;
    }
 else {
      final String msg=className + "String_Node_Str";
      LOG.error(msg);
      throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
    }
  }
 catch (  final ClassNotFoundException e) {
    final String msg="String_Node_Str" + className;
    LOG.error(msg,e);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
catch (  final BeansException e) {
    final String msg="String_Node_Str" + className;
    LOG.error(msg,e);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
}
Program: 90139
Project: 90139
Buggy source:
/** 
 * Wait until the job finishes, and then return exit code. Also ensure that stdout is within the limit (if specified), and update DB status periodically (as RUNNING).
 * @return exit code for the job after it finishes
 */
@Transactional private int waitForExit(){
  this.lastUpdatedTimeMS=System.currentTimeMillis();
  while (isRunning()) {
    try {
      Thread.sleep(JOB_WAIT_TIME_MS);
    }
 catch (    InterruptedException e) {
      LOG.error("String_Node_Str" + job.getId() + "String_Node_Str",e);
    }
    if (shouldUpdateJob()) {
      LOG.debug("String_Node_Str" + job.getId());
      this.lastUpdatedTimeMS=System.currentTimeMillis();
      this.job.setJobStatus(JobStatus.RUNNING,"String_Node_Str");
      this.job.setUpdated(new Date(this.lastUpdatedTimeMS));
      try {
        final Job dbJI=this.em.find(Job.class,this.job.getId());
        if ((dbJI.getStatus() != null) && dbJI.getStatus() != JobStatus.KILLED) {
          this.job.setUpdated(new Date());
          this.em.merge(this.job);
        }
      }
 catch (      Exception e) {
        LOG.error("String_Node_Str" + this.job.getId(),e);
      }
      if (this.stdOutFile != null && this.stdOutFile.exists() && this.maxStdoutSize != null && this.stdOutFile.length() > this.maxStdoutSize && !this.terminated) {
        LOG.warn("String_Node_Str" + this.job.getId() + "String_Node_Str");
        try {
          this.jobManager.kill(this.job);
          this.terminated=true;
        }
 catch (        GenieException e) {
          LOG.error("String_Node_Str" + this.job.getId() + "String_Node_Str",e);
        }
      }
    }
  }
  return this.proc.exitValue();
}

Fixed version (ground truth):
/** 
 * Wait until the job finishes, and then return exit code. Also ensure that stdout is within the limit (if specified), and update DB status periodically (as RUNNING).
 * @return exit code for the job after it finishes
 */
private int waitForExit(){
  this.lastUpdatedTimeMS=System.currentTimeMillis();
  while (isRunning()) {
    try {
      Thread.sleep(JOB_WAIT_TIME_MS);
    }
 catch (    InterruptedException e) {
      LOG.error("String_Node_Str" + this.jobId + "String_Node_Str",e);
    }
    if (shouldUpdateJob()) {
      updateJob();
      if (this.stdOutFile != null && this.stdOutFile.exists() && this.maxStdoutSize != null && this.stdOutFile.length() > this.maxStdoutSize && !this.terminated) {
        LOG.warn("String_Node_Str" + this.jobId + "String_Node_Str");
        try {
          this.jobManager.kill();
          this.terminated=true;
        }
 catch (        GenieException e) {
          LOG.error("String_Node_Str" + this.jobId + "String_Node_Str",e);
        }
      }
    }
  }
  return this.proc.exitValue();
}
Program: 90141
Project: 90141
Buggy source:
/** 
 * Constructor.
 * @param genieNodeStatistics The statistics object to use
 */
@Inject public JobMonitorImpl(final GenieNodeStatistics genieNodeStatistics){
  this.genieNodeStatistics=genieNodeStatistics;
  this.config=ConfigurationManager.getConfigInstance();
  this.maxStdoutSize=this.config.getLong("String_Node_Str",null);
  this.job=null;
  this.workingDir=null;
  this.proc=null;
  this.stdOutFile=null;
}

Fixed version (ground truth):
/** 
 * Constructor.
 * @param jobRepo The job repository
 * @param genieNodeStatistics The statistics object to use
 */
@Inject public JobMonitorImpl(final JobRepository jobRepo,final GenieNodeStatistics genieNodeStatistics){
  this.jobRepo=jobRepo;
  this.genieNodeStatistics=genieNodeStatistics;
  this.config=ConfigurationManager.getConfigInstance();
  this.maxStdoutSize=this.config.getLong("String_Node_Str",null);
  this.workingDir=null;
  this.proc=null;
  this.stdOutFile=null;
}
Program: 90142
Project: 90142
Buggy source:
/** 
 * Set the job for this to monitor.
 * @param job The job to monitor. Not null.
 * @throws GenieException
 */
@Override public void setJob(final Job job) throws GenieException {
  if (job == null) {
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,"String_Node_Str");
  }
  this.job=job;
}

Fixed version (ground truth):
/** 
 * Set the job for this to monitor.
 * @param job The job to monitor. Not null.
 * @throws GenieException
 */
@Override public void setJob(final Job job) throws GenieException {
  if (job == null || StringUtils.isBlank(job.getId())) {
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,"String_Node_Str");
  }
  this.jobId=job.getId();
}
Program: 90143
Project: 90143
Buggy source:
/** 
 * The main run method for this thread - wait till it finishes, and manage job state in DB.
 */
@Override public void run(){
  boolean killed=false;
  int exitCode=waitForExit();
  this.job.setExitCode(exitCode);
  final Job dbJI=this.em.find(Job.class,this.job.getId());
  if (dbJI.getStatus() != null && dbJI.getStatus() != JobStatus.KILLED) {
    if (exitCode != SubProcessStatus.SUCCESS.code()) {
      LOG.error("String_Node_Str" + exitCode);
      String errMsg=SubProcessStatus.message(exitCode);
      if ((errMsg == null) || (errMsg.isEmpty())) {
        errMsg="String_Node_Str";
      }
      this.job.setJobStatus(JobStatus.FAILED,"String_Node_Str" + errMsg);
      this.genieNodeStatistics.incrGenieFailedJobs();
    }
 else {
      this.job.setJobStatus(JobStatus.SUCCEEDED,"String_Node_Str");
      this.genieNodeStatistics.incrGenieSuccessfulJobs();
    }
    if (!this.job.isDisableLogArchival()) {
      this.job.setArchiveLocation(NetUtil.getArchiveURI(this.job.getId()));
    }
    this.job.setUpdated(new Date());
    this.em.merge(this.job);
  }
 else {
    LOG.debug("String_Node_Str" + job.getId());
    killed=true;
  }
  final String emailTo=this.job.getEmail();
  if (emailTo != null) {
    LOG.info("String_Node_Str" + emailTo);
    if (sendEmail(emailTo,killed)) {
      this.genieNodeStatistics.incrSuccessfulEmailCount();
    }
 else {
      LOG.warn("String_Node_Str");
      this.genieNodeStatistics.incrFailedEmailCount();
    }
  }
}

Fixed version (ground truth):
/** 
 * The main run method for this thread - wait till it finishes, and manage job state in DB.
 */
@Override public void run(){
  final boolean killed=this.finalizeJob(waitForExit()) == JobStatus.KILLED;
  final String emailTo=this.jobRepo.findOne(this.jobId).getEmail();
  if (emailTo != null) {
    LOG.info("String_Node_Str" + emailTo);
    if (sendEmail(emailTo,killed)) {
      this.genieNodeStatistics.incrSuccessfulEmailCount();
    }
 else {
      LOG.warn("String_Node_Str");
      this.genieNodeStatistics.incrFailedEmailCount();
    }
  }
}
Program: 90144
Project: 90144
Buggy source:
/** 
 * Set command Name with which this job is run.
 * @param commandName Name of the command if specified on which the job isrun
 * @throws GenieException
 */
public void setCommandName(final String commandName) throws GenieException {
  if (StringUtils.isBlank(commandName)) {
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,"String_Node_Str");
  }
  this.commandName=commandName;
}

Fixed version (ground truth):
/** 
 * Set command Name with which this job is run.
 * @param commandName Name of the command if specified on which the job isrun
 */
public void setCommandName(final String commandName){
  this.commandName=commandName;
}
Program: 90145
Project: 90145
Buggy source:
/** 
 * Helper method for building the cluster criteria string.
 * @param clusterCriteria2 The criteria to build up from
 * @return The cluster criteria string
 */
private String clusterCriteriaToString(final List<ClusterCriteria> clusterCriteria2) throws GenieException {
  if (clusterCriteria2 == null || clusterCriteria2.isEmpty()) {
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,"String_Node_Str");
  }
  final StringBuilder builder=new StringBuilder();
  for (  final ClusterCriteria cc : clusterCriteria2) {
    if (builder.length() != 0) {
      builder.append(CRITERIA_SET_DELIMITER);
    }
    builder.append(StringUtils.join(cc.getTags(),CRITERIA_DELIMITER));
  }
  return builder.toString();
}

Fixed version (ground truth):
/** 
 * Helper method for building the cluster criteria string.
 * @param clusterCriteria2 The criteria to build up from
 * @return The cluster criteria string
 */
private String clusterCriteriaToString(final List<ClusterCriteria> clusterCriteria2){
  if (clusterCriteria2 == null || clusterCriteria2.isEmpty()) {
    return null;
  }
  final StringBuilder builder=new StringBuilder();
  for (  final ClusterCriteria cc : clusterCriteria2) {
    if (builder.length() != 0) {
      builder.append(CRITERIA_SET_DELIMITER);
    }
    builder.append(StringUtils.join(cc.getTags(),CRITERIA_DELIMITER));
  }
  return builder.toString();
}
Program: 90146
Project: 90146
Buggy source:
/** 
 * Set the cluster criteria string.
 * @param clusterCriteriaString A list of cluster criteria objects
 * @throws GenieException
 */
protected void setClusterCriteriaString(final String clusterCriteriaString) throws GenieException {
  if (StringUtils.isBlank(clusterCriteriaString)) {
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,"String_Node_Str");
  }
  this.clusterCriteriaString=clusterCriteriaString;
  this.clusterCriteria=stringToClusterCriteria(clusterCriteriaString);
}

Fixed version (ground truth):
/** 
 * Set the cluster criteria string.
 * @param clusterCriteriaString A list of cluster criteria objects
 * @throws GenieException 
 */
protected void setClusterCriteriaString(final String clusterCriteriaString) throws GenieException {
  this.clusterCriteriaString=clusterCriteriaString;
  this.clusterCriteria=stringToClusterCriteria(clusterCriteriaString);
}
Program: 90147
Project: 90147
Buggy source:
/** 
 * Set command Id with which this job is run.
 * @param commandId Id of the command if specified on which the job is run
 * @throws com.netflix.genie.common.exceptions.GenieException
 */
public void setCommandId(final String commandId) throws GenieException {
  if (StringUtils.isBlank(commandId)) {
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,"String_Node_Str");
  }
  this.commandId=commandId;
}

Fixed version (ground truth):
/** 
 * Set command Id with which this job is run.
 * @param commandId Id of the command if specified on which the job is run
 */
public void setCommandId(final String commandId){
  this.commandId=commandId;
}
Program: 90148
Project: 90148
Buggy source:
/** 
 * Kill job based on given job ID.
 * @param id id for job to kill
 * @return The job that was killed
 * @throws GenieException
 */
@DELETE @Path("String_Node_Str") @ApiOperation(value="String_Node_Str",notes="String_Node_Str",response=Job.class) @ApiResponses(value={@ApiResponse(code=200,message="String_Node_Str",response=Job.class)}) public Job killJob(@PathParam("String_Node_Str") @ApiParam(value="String_Node_Str",required=true) final String id) throws GenieException {
  LOG.debug("String_Node_Str" + id);
  return this.xs.killJob(id);
}

Fixed version (ground truth):
/** 
 * Kill job based on given job ID.
 * @param id id for job to kill
 * @return The job that was killed
 * @throws GenieException
 */
@DELETE @Path("String_Node_Str") @ApiOperation(value="String_Node_Str",notes="String_Node_Str",response=Job.class) @ApiResponses(value={@ApiResponse(code=200,message="String_Node_Str",response=Job.class)}) public Job killJob(@ApiParam(value="String_Node_Str",required=true) @PathParam("String_Node_Str") final String id) throws GenieException {
  LOG.debug("String_Node_Str" + id);
  return this.xs.killJob(id);
}
Program: 90150
Project: 90150
Buggy source:
/** 
 * Add some more tags to a given application.
 * @param id The id of the application to add tags to. NotNull/empty/blank.
 * @param tags The tags to add. Not null or empty.
 * @return The new set of tags for the given application.
 * @throws GenieException
 */
public Set<String> addTagsToApplication(final String id,final Set<String> tags) throws GenieException {
  if (StringUtils.isBlank(id)) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  if (tags == null || tags.isEmpty()) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  final HttpRequest request=this.buildRequest(Verb.POST,StringUtils.join(new String[]{BASE_CONFIG_APPLICATION_REST_URL,id,"String_Node_Str"},SLASH),null,tags);
  return (Set<String>)this.executeRequest(request,Set.class,String.class);
}

Fixed version (ground truth):
/** 
 * Add some more tags to a given application.
 * @param id   The id of the application to add tags to. NotNull/empty/blank.
 * @param tags The tags to add. Not null or empty.
 * @return The new set of tags for the given application.
 * @throws GenieException
 */
public Set<String> addTagsToApplication(final String id,final Set<String> tags) throws GenieException {
  if (StringUtils.isBlank(id)) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  if (tags == null || tags.isEmpty()) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  final HttpRequest request=this.buildRequest(Verb.POST,StringUtils.join(new String[]{BASE_CONFIG_APPLICATION_REST_URL,id,"String_Node_Str"},SLASH),null,tags);
  return (Set<String>)this.executeRequest(request,Set.class,String.class);
}
Program: 90151
Project: 90151
Buggy source:
/** 
 * Update the configuration files for a given application.
 * @param id The id of the application to update the configuration filesfor. Not null/empty/blank.
 * @param configs The configuration files to replace existing configurationfiles with. Not null.
 * @return The new set of application configurations.
 * @throws GenieException
 */
public Set<String> updateConfigsForApplication(final String id,final Set<String> configs) throws GenieException {
  if (StringUtils.isBlank(id)) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  if (configs == null) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  final HttpRequest request=this.buildRequest(Verb.PUT,StringUtils.join(new String[]{BASE_CONFIG_APPLICATION_REST_URL,id,"String_Node_Str"},SLASH),null,configs);
  return (Set<String>)this.executeRequest(request,Set.class,String.class);
}

Fixed version (ground truth):
/** 
 * Update the configuration files for a given application.
 * @param id      The id of the application to update the configuration filesfor. Not null/empty/blank.
 * @param configs The configuration files to replace existing configurationfiles with. Not null.
 * @return The new set of application configurations.
 * @throws GenieException
 */
public Set<String> updateConfigsForApplication(final String id,final Set<String> configs) throws GenieException {
  if (StringUtils.isBlank(id)) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  if (configs == null) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  final HttpRequest request=this.buildRequest(Verb.PUT,StringUtils.join(new String[]{BASE_CONFIG_APPLICATION_REST_URL,id,"String_Node_Str"},SLASH),null,configs);
  return (Set<String>)this.executeRequest(request,Set.class,String.class);
}
Program: 90152
Project: 90152
Buggy source:
/** 
 * Update the tags for a given application.
 * @param id The id of the application to update the tags for.Not null/empty/blank.
 * @param tags The tags to replace existing tagfiles with. Not null.
 * @return The new set of application tags.
 * @throws GenieException
 */
public Set<String> updateTagsForApplication(final String id,final Set<String> tags) throws GenieException {
  if (StringUtils.isBlank(id)) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  if (tags == null) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  final HttpRequest request=this.buildRequest(Verb.PUT,StringUtils.join(new String[]{BASE_CONFIG_APPLICATION_REST_URL,id,"String_Node_Str"},SLASH),null,tags);
  return (Set<String>)this.executeRequest(request,Set.class,String.class);
}

Fixed version (ground truth):
/** 
 * Update the tags for a given application.
 * @param id   The id of the application to update the tags for.Not null/empty/blank.
 * @param tags The tags to replace existing tagfiles with. Not null.
 * @return The new set of application tags.
 * @throws GenieException
 */
public Set<String> updateTagsForApplication(final String id,final Set<String> tags) throws GenieException {
  if (StringUtils.isBlank(id)) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  if (tags == null) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  final HttpRequest request=this.buildRequest(Verb.PUT,StringUtils.join(new String[]{BASE_CONFIG_APPLICATION_REST_URL,id,"String_Node_Str"},SLASH),null,tags);
  return (Set<String>)this.executeRequest(request,Set.class,String.class);
}
Program: 90153
Project: 90153
Buggy source:
/** 
 * Create or update an application configuration.
 * @param id the id for the application to create or update
 * @param application the object encapsulating the new application to create
 * @return extracted application configuration response
 * @throws GenieException
 */
public Application updateApplication(final String id,final Application application) throws GenieException {
  if (StringUtils.isBlank(id)) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  final HttpRequest request=this.buildRequest(Verb.PUT,StringUtils.join(new String[]{BASE_CONFIG_APPLICATION_REST_URL,id},SLASH),null,application);
  return (Application)this.executeRequest(request,null,Application.class);
}

Fixed version (ground truth):
/** 
 * Create or update an application configuration.
 * @param id          the id for the application to create or update
 * @param application the object encapsulating the new application to create
 * @return extracted application configuration response
 * @throws GenieException
 */
public Application updateApplication(final String id,final Application application) throws GenieException {
  if (StringUtils.isBlank(id)) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  final HttpRequest request=this.buildRequest(Verb.PUT,StringUtils.join(new String[]{BASE_CONFIG_APPLICATION_REST_URL,id},SLASH),null,application);
  return (Application)this.executeRequest(request,null,Application.class);
}
Program: 90154
Project: 90154
Buggy source:
/** 
 * Add some more configuration files to a given application.
 * @param id The id of the application to add configurations to. NotNull/empty/blank.
 * @param configs The configuration files to add. Not null or empty.
 * @return The new set of configuration files for the given application.
 * @throws GenieException
 */
public Set<String> addConfigsToApplication(final String id,final Set<String> configs) throws GenieException {
  if (StringUtils.isBlank(id)) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  if (configs == null || configs.isEmpty()) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  final HttpRequest request=this.buildRequest(Verb.POST,StringUtils.join(new String[]{BASE_CONFIG_APPLICATION_REST_URL,id,"String_Node_Str"},SLASH),null,configs);
  return (Set<String>)this.executeRequest(request,Set.class,String.class);
}

Fixed version (ground truth):
/** 
 * Add some more configuration files to a given application.
 * @param id      The id of the application to add configurations to. NotNull/empty/blank.
 * @param configs The configuration files to add. Not null or empty.
 * @return The new set of configuration files for the given application.
 * @throws GenieException
 */
public Set<String> addConfigsToApplication(final String id,final Set<String> configs) throws GenieException {
  if (StringUtils.isBlank(id)) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  if (configs == null || configs.isEmpty()) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  final HttpRequest request=this.buildRequest(Verb.POST,StringUtils.join(new String[]{BASE_CONFIG_APPLICATION_REST_URL,id,"String_Node_Str"},SLASH),null,configs);
  return (Set<String>)this.executeRequest(request,Set.class,String.class);
}
Program: 90155
Project: 90155
Buggy source:
/** 
 * Gets a set of application configurations for the given parameters.
 * @param params key/value pairs in a map object.<br>More details on the parameters can be found on the Genie User Guide on GitHub.
 * @return List of application configuration elements that match the filter
 * @throws GenieException
 */
public List<Application> getApplications(final Multimap<String,String> params) throws GenieException {
  final HttpRequest request=this.buildRequest(Verb.GET,BASE_CONFIG_APPLICATION_REST_URL,params,null);
  return (List<Application>)this.executeRequest(request,List.class,Application.class);
}

Fixed version (ground truth):
/** 
 * Gets a set of application configurations for the given parameters.
 * @param params key/value pairs in a map object.<br><p/> More details on the parameters can be found on the Genie User Guide on GitHub.
 * @return List of application configuration elements that match the filter
 * @throws GenieException
 */
public List<Application> getApplications(final Multimap<String,String> params) throws GenieException {
  final HttpRequest request=this.buildRequest(Verb.GET,BASE_CONFIG_APPLICATION_REST_URL,params,null);
  return (List<Application>)this.executeRequest(request,List.class,Application.class);
}
Program: 90156
Project: 90156
Buggy source:
/** 
 * Add some more jar files to a given application.
 * @param id The id of the application to add jars to. NotNull/empty/blank.
 * @param jars The jar files to add. Not null or empty.
 * @return The new set of jar files for the given application.
 * @throws GenieException
 */
public Set<String> addJarsToApplication(final String id,final Set<String> jars) throws GenieException {
  if (StringUtils.isBlank(id)) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  if (jars == null || jars.isEmpty()) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  final HttpRequest request=this.buildRequest(Verb.POST,StringUtils.join(new String[]{BASE_CONFIG_APPLICATION_REST_URL,id,"String_Node_Str"},SLASH),null,jars);
  return (Set<String>)this.executeRequest(request,Set.class,String.class);
}

Fixed version (ground truth):
/** 
 * Add some more jar files to a given application.
 * @param id   The id of the application to add jars to. NotNull/empty/blank.
 * @param jars The jar files to add. Not null or empty.
 * @return The new set of jar files for the given application.
 * @throws GenieException
 */
public Set<String> addJarsToApplication(final String id,final Set<String> jars) throws GenieException {
  if (StringUtils.isBlank(id)) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  if (jars == null || jars.isEmpty()) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  final HttpRequest request=this.buildRequest(Verb.POST,StringUtils.join(new String[]{BASE_CONFIG_APPLICATION_REST_URL,id,"String_Node_Str"},SLASH),null,jars);
  return (Set<String>)this.executeRequest(request,Set.class,String.class);
}
Program: 90157
Project: 90157
Buggy source:
/** 
 * Update the jar files for a given application.
 * @param id The id of the application to update the jar filesfor. Not null/empty/blank.
 * @param jars The jar files to replace existing jarfiles with. Not null.
 * @return The new set of application jars.
 * @throws GenieException
 */
public Set<String> updateJarsForApplication(final String id,final Set<String> jars) throws GenieException {
  if (StringUtils.isBlank(id)) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  if (jars == null) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  final HttpRequest request=this.buildRequest(Verb.PUT,StringUtils.join(new String[]{BASE_CONFIG_APPLICATION_REST_URL,id,"String_Node_Str"},SLASH),null,jars);
  return (Set<String>)this.executeRequest(request,Set.class,String.class);
}

Fixed version (ground truth):
/** 
 * Update the jar files for a given application.
 * @param id   The id of the application to update the jar filesfor. Not null/empty/blank.
 * @param jars The jar files to replace existing jarfiles with. Not null.
 * @return The new set of application jars.
 * @throws GenieException
 */
public Set<String> updateJarsForApplication(final String id,final Set<String> jars) throws GenieException {
  if (StringUtils.isBlank(id)) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  if (jars == null) {
    final String msg="String_Node_Str";
    LOG.error(msg);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,msg);
  }
  final HttpRequest request=this.buildRequest(Verb.PUT,StringUtils.join(new String[]{BASE_CONFIG_APPLICATION_REST_URL,id,"String_Node_Str"},SLASH),null,jars);
  return (Set<String>)this.executeRequest(request,Set.class,String.class);
}
Program: 90158
Project: 90158
Buggy source:
/** 
 * Build a HTTP request from the given parameters.
 * @param verb The type of HTTP request to use.
 * @param requestUri The URI to send the request to.
 * @param params Any query parameters to send along with the request.
 * @param entity An entity if required to add to the request.
 * @return The HTTP request.
 * @throws GenieException
 */
protected HttpRequest buildRequest(final Verb verb,final String requestUri,final Multimap<String,String> params,final Object entity) throws GenieException {
  try {
    final HttpRequest.Builder builder=HttpRequest.newBuilder().verb(verb).header(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON).header(HttpHeaders.ACCEPT,MediaType.APPLICATION_JSON).uri(new URI(requestUri)).entity(entity);
    if (params != null) {
      for (      final Entry<String,String> param : params.entries()) {
        builder.queryParams(param.getKey(),param.getValue());
      }
    }
    return builder.build();
  }
 catch (  final URISyntaxException use) {
    LOG.error(use.getMessage(),use);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,use);
  }
}

Fixed version (ground truth):
/** 
 * Build a HTTP request from the given parameters.
 * @param verb       The type of HTTP request to use.
 * @param requestUri The URI to send the request to.
 * @param params     Any query parameters to send along with the request.
 * @param entity     An entity if required to add to the request.
 * @return The HTTP request.
 * @throws GenieException
 */
protected HttpRequest buildRequest(final Verb verb,final String requestUri,final Multimap<String,String> params,final Object entity) throws GenieException {
  try {
    final HttpRequest.Builder builder=HttpRequest.newBuilder().verb(verb).header(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON).header(HttpHeaders.ACCEPT,MediaType.APPLICATION_JSON).uri(new URI(requestUri)).entity(entity);
    if (params != null) {
      for (      final Entry<String,String> param : params.entries()) {
        builder.queryParams(param.getKey(),param.getValue());
      }
    }
    return builder.build();
  }
 catch (  final URISyntaxException use) {
    LOG.error(use.getMessage(),use);
    throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,use);
  }
}
Program: 90159
Project: 90159
Buggy source:
/** 
 * Execute a HTTP request.
 * @param < C > The collection class if a collection is the expected responseentity.
 * @param request The request to send
 * @param collectionClass The collection class. Null if none expected.
 * @param entityClass The entity class. Not null.
 * @return The response entity.
 * @throws GenieException
 */
protected <C extends Collection>Object executeRequest(final HttpRequest request,final Class<C> collectionClass,final Class entityClass) throws GenieException {
  HttpResponse response=null;
  try {
    response=this.client.executeWithLoadBalancer(request);
    if (response.isSuccess()) {
      if (collectionClass != null) {
        final ObjectMapper mapper=new ObjectMapper();
        final CollectionType type=mapper.getTypeFactory().constructCollectionType(collectionClass,entityClass);
        return mapper.readValue(response.getInputStream(),type);
      }
 else       if (entityClass != null) {
        return response.getEntity(entityClass);
      }
 else {
        throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,"String_Node_Str");
      }
    }
 else {
      throw new GenieException(response.getStatus(),response.getEntity(String.class));
    }
  }
 catch (  final Exception e) {
    if (e instanceof GenieException) {
      throw (GenieException)e;
    }
 else {
      LOG.error(e.getMessage(),e);
      throw new GenieException(HttpURLConnection.HTTP_INTERNAL_ERROR,e);
    }
  }
 finally {
    if (response != null) {
      response.close();
    }
  }
}

Fixed version (ground truth):
/** 
 * Execute a HTTP request.
 * @param < C >             The collection class if a collection is the expected responseentity.
 * @param request         The request to send
 * @param collectionClass The collection class. Null if none expected.
 * @param entityClass     The entity class. Not null.
 * @return The response entity.
 * @throws GenieException
 */
protected <C extends Collection>Object executeRequest(final HttpRequest request,final Class<C> collectionClass,final Class entityClass) throws GenieException {
  HttpResponse response=null;
  try {
    response=this.client.executeWithLoadBalancer(request);
    if (response.isSuccess()) {
      if (collectionClass != null) {
        final ObjectMapper mapper=new ObjectMapper();
        final CollectionType type=mapper.getTypeFactory().constructCollectionType(collectionClass,entityClass);
        return mapper.readValue(response.getInputStream(),type);
      }
 else       if (entityClass != null) {
        return response.getEntity(entityClass);
      }
 else {
        throw new GenieException(HttpURLConnection.HTTP_BAD_REQUEST,"String_Node_Str");
      }
    }
 else {
      throw new GenieException(response.getStatus(),response.getEntity(String.class));
    }
  }
 catch (  final Exception e) {
    if (e instanceof GenieException) {
      throw (GenieException)e;
    }
 else {
      LOG.error(e.getMessage(),e);
      throw new GenieException(HttpURLConnection.HTTP_INTERNAL_ERROR,e);
    }
  }
 finally {
    if (response != null) {
      response.close();
    }
  }
}
Program: 90160
Project: 90160
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void setJobStatus(final String id,final JobStatus status,final String msg) throws GenieException {
  LOG.debug("String_Node_Str" + id + "String_Node_Str"+ msg);
  final Job job=this.jobRepo.findOne(id);
  if (job != null) {
    job.setJobStatus(status,msg);
  }
 else {
    throw new GenieException(HttpURLConnection.HTTP_NOT_FOUND,"String_Node_Str" + id + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void setJobStatus(final String id,final JobStatus status,final String msg) throws GenieException {
  LOG.debug("String_Node_Str" + id + "String_Node_Str"+ status+ "String_Node_Str"+ msg);
  final Job job=this.jobRepo.findOne(id);
  if (job != null) {
    job.setJobStatus(status,msg);
  }
 else {
    throw new GenieException(HttpURLConnection.HTTP_NOT_FOUND,"String_Node_Str" + id + "String_Node_Str");
  }
}
Program: 90161
Project: 90161
Buggy source:
/** 
 * Initializes the object with the job information and environment prior to job launch This method must be called before job is launched.
 * @param ji2 the JobInfo object passed by the user
 * @throws CloudServiceException if there is an error during initialization
 */
protected void init(Job ji2) throws CloudServiceException {
  LOG.info("String_Node_Str");
  genieJobIDProp=GENIE_JOB_ID + "String_Node_Str" + ji2.getId();
  netflixEnvProp=NFLX_ENV + "String_Node_Str" + ConfigurationManager.getConfigInstance().getString("String_Node_Str");
  String lipstickUuidPropName=ConfigurationManager.getConfigInstance().getString("String_Node_Str","String_Node_Str");
  if (ConfigurationManager.getConfigInstance().getBoolean("String_Node_Str",false)) {
    lipstickUuidProp=lipstickUuidPropName + "String_Node_Str" + GENIE_JOB_ID;
  }
  this.env=initEnv(ji2);
  this.args=initArgs(ji2);
  this.ji=ji2;
}

Fixed version (ground truth):
/** 
 * Initializes the object with the job information and environment prior to job launch This method must be called before job is launched.
 * @param job the JobInfo object passed by the user
 * @throws CloudServiceException if there is an error during initialization
 */
protected void init(final Job job) throws CloudServiceException {
  LOG.info("String_Node_Str");
  genieJobIDProp=GENIE_JOB_ID + "String_Node_Str" + job.getId();
  netflixEnvProp=NFLX_ENV + "String_Node_Str" + ConfigurationManager.getConfigInstance().getString("String_Node_Str");
  String lipstickUuidPropName=ConfigurationManager.getConfigInstance().getString("String_Node_Str","String_Node_Str");
  if (ConfigurationManager.getConfigInstance().getBoolean("String_Node_Str",false)) {
    lipstickUuidProp=lipstickUuidPropName + "String_Node_Str" + GENIE_JOB_ID;
  }
  this.env=initEnv(job);
  this.args=initArgs(job);
  this.ji=job;
}