Program: 90172
Project: 90172
Buggy source:
/** 
 * The main run method for this thread - wait till it finishes, and manage job state in DB.
 */
@Override public void run(){
  int exitCode=waitForExit();
  ji.setExitCode(exitCode);
  ReentrantReadWriteLock rwl=PersistenceManager.getDbLock();
  try {
    rwl.writeLock().lock();
    JobInfoElement dbJI=pm.getEntity(ji.getJobID(),JobInfoElement.class);
    if ((dbJI.getStatus() != null) && !dbJI.getStatus().equalsIgnoreCase("String_Node_Str")) {
      GenieNodeStatistics stats=GenieNodeStatistics.getInstance();
      if (exitCode != SubprocessStatus.SUCCESS.code()) {
        logger.error("String_Node_Str" + exitCode);
        String errMsg=Types.SubprocessStatus.message(exitCode);
        if ((errMsg == null) || (errMsg.isEmpty())) {
          errMsg="String_Node_Str";
        }
        ji.setJobStatus(JobStatus.FAILED,"String_Node_Str" + errMsg);
        stats.incrGenieFailedJobs();
      }
 else {
        ji.setJobStatus(JobStatus.SUCCEEDED,"String_Node_Str");
        stats.incrGenieSuccessfulJobs();
      }
      if (!ji.getDisableLogArchival()) {
        ji.setArchiveLocation(NetUtil.getArchiveURI(ji.getJobID()));
      }
      pm.updateEntity(ji);
      rwl.writeLock().unlock();
    }
 else {
      logger.debug("String_Node_Str" + ji.getJobID());
      rwl.writeLock().unlock();
    }
    if (config.getBoolean("String_Node_Str",false) == false) {
      logger.info("String_Node_Str");
    }
 else {
      logger.info("String_Node_Str");
      if (sendEmail() != 0) {
        logger.warn("String_Node_Str");
      }
    }
  }
  finally {
    if (rwl.writeLock().isHeldByCurrentThread()) {
      rwl.writeLock().unlock();
    }
  }
}

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(){
  int exitCode=waitForExit();
  ji.setExitCode(exitCode);
  ReentrantReadWriteLock rwl=PersistenceManager.getDbLock();
  try {
    rwl.writeLock().lock();
    JobInfoElement dbJI=pm.getEntity(ji.getJobID(),JobInfoElement.class);
    if ((dbJI.getStatus() != null) && !dbJI.getStatus().equalsIgnoreCase("String_Node_Str")) {
      GenieNodeStatistics stats=GenieNodeStatistics.getInstance();
      if (exitCode != SubprocessStatus.SUCCESS.code()) {
        logger.error("String_Node_Str" + exitCode);
        String errMsg=Types.SubprocessStatus.message(exitCode);
        if ((errMsg == null) || (errMsg.isEmpty())) {
          errMsg="String_Node_Str";
        }
        ji.setJobStatus(JobStatus.FAILED,"String_Node_Str" + errMsg);
        stats.incrGenieFailedJobs();
      }
 else {
        ji.setJobStatus(JobStatus.SUCCEEDED,"String_Node_Str");
        stats.incrGenieSuccessfulJobs();
      }
      if (!ji.getDisableLogArchival()) {
        ji.setArchiveLocation(NetUtil.getArchiveURI(ji.getJobID()));
      }
      pm.updateEntity(ji);
      rwl.writeLock().unlock();
    }
 else {
      logger.debug("String_Node_Str" + ji.getJobID());
      rwl.writeLock().unlock();
    }
    if (config.getBoolean("String_Node_Str",false)) {
      logger.info("String_Node_Str");
      if (sendEmail() != 0) {
        logger.warn("String_Node_Str");
      }
    }
 else {
      logger.info("String_Node_Str");
    }
  }
  finally {
    if (rwl.writeLock().isHeldByCurrentThread()) {
      rwl.writeLock().unlock();
    }
  }
}