Program: 9775
Project: 9775
Buggy source:
public List<OperableTrigger> acquireNextTriggers(long noLaterThan,int maxCount,long timeWindow) throws JobPersistenceException {
  BasicDBObject query=new BasicDBObject();
  query.put(TRIGGER_NEXT_FIRE_TIME,new BasicDBObject("String_Node_Str",new Date(noLaterThan)));
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + maxCount + "String_Node_Str"+ new Date(noLaterThan));
  }
  List<OperableTrigger> triggers=new ArrayList<OperableTrigger>();
  DBCursor cursor=triggerCollection.find(query);
  BasicDBObject sort=new BasicDBObject();
  sort.put(TRIGGER_NEXT_FIRE_TIME,Integer.valueOf(1));
  cursor.sort(sort);
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + cursor.count() + "String_Node_Str");
  }
  while (cursor.hasNext() && maxCount > triggers.size()) {
    DBObject dbObj=cursor.next();
    BasicDBObject lock=new BasicDBObject();
    lock.put(LOCK_KEY_NAME,dbObj.get(KEY_NAME));
    lock.put(LOCK_KEY_GROUP,dbObj.get(KEY_GROUP));
    lock.put(LOCK_INSTANCE_ID,instanceId);
    lock.put(LOCK_TIME,new Date());
    try {
      OperableTrigger trigger=toTrigger(dbObj);
      if (trigger.getNextFireTime() == null) {
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + trigger.getKey() + "String_Node_Str");
        }
        continue;
      }
      if (applyMisfire(trigger) && trigger.getNextFireTime() == null) {
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + trigger.getKey() + "String_Node_Str");
        }
        continue;
      }
      log.debug("String_Node_Str" + trigger.getKey());
      locksCollection.insert(lock);
      log.debug("String_Node_Str" + trigger.getKey());
      triggers.add(trigger);
    }
 catch (    DuplicateKey e) {
      OperableTrigger trigger=toTrigger(dbObj);
      log.debug("String_Node_Str" + trigger.getKey() + "String_Node_Str");
      lock=new BasicDBObject();
      lock.put(LOCK_KEY_NAME,dbObj.get(KEY_NAME));
      lock.put(LOCK_KEY_GROUP,dbObj.get(KEY_GROUP));
      DBObject existingLock;
      DBCursor lockCursor=locksCollection.find(lock);
      if (lockCursor.hasNext()) {
        existingLock=lockCursor.next();
      }
 else {
        log.error("String_Node_Str");
        return acquireNextTriggers(noLaterThan,maxCount,timeWindow);
      }
      if (isTriggerLockExpired(existingLock)) {
        log.error("String_Node_Str" + trigger.getKey() + "String_Node_Str");
        removeTriggerLock(trigger);
        return acquireNextTriggers(noLaterThan,maxCount,timeWindow);
      }
    }
  }
  return triggers;
}

Fixed version (ground truth):
public List<OperableTrigger> acquireNextTriggers(long noLaterThan,int maxCount,long timeWindow) throws JobPersistenceException {
  BasicDBObject query=new BasicDBObject();
  query.put(TRIGGER_NEXT_FIRE_TIME,new BasicDBObject("String_Node_Str",new Date(noLaterThan)));
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + maxCount + "String_Node_Str"+ new Date(noLaterThan));
  }
  List<OperableTrigger> triggers=new ArrayList<OperableTrigger>();
  DBCursor cursor=triggerCollection.find(query);
  BasicDBObject sort=new BasicDBObject();
  sort.put(TRIGGER_NEXT_FIRE_TIME,Integer.valueOf(1));
  cursor.sort(sort);
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + cursor.count() + "String_Node_Str");
  }
  while (cursor.hasNext() && maxCount > triggers.size()) {
    DBObject dbObj=cursor.next();
    BasicDBObject lock=new BasicDBObject();
    lock.put(LOCK_KEY_NAME,dbObj.get(KEY_NAME));
    lock.put(LOCK_KEY_GROUP,dbObj.get(KEY_GROUP));
    lock.put(LOCK_INSTANCE_ID,instanceId);
    lock.put(LOCK_TIME,new Date());
    try {
      OperableTrigger trigger=toTrigger(dbObj);
      if (trigger.getNextFireTime() == null) {
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + trigger.getKey() + "String_Node_Str");
        }
        continue;
      }
      if (applyMisfire(trigger) && trigger.getNextFireTime() == null) {
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + trigger.getKey() + "String_Node_Str");
        }
        continue;
      }
      log.debug("String_Node_Str" + trigger.getKey());
      locksCollection.insert(lock);
      log.debug("String_Node_Str" + trigger.getKey());
      triggers.add(trigger);
    }
 catch (    DuplicateKey e) {
      OperableTrigger trigger=toTrigger(dbObj);
      log.debug("String_Node_Str" + trigger.getKey() + "String_Node_Str");
      lock=new BasicDBObject();
      lock.put(LOCK_KEY_NAME,dbObj.get(KEY_NAME));
      lock.put(LOCK_KEY_GROUP,dbObj.get(KEY_GROUP));
      DBObject existingLock;
      DBCursor lockCursor=locksCollection.find(lock);
      if (lockCursor.hasNext()) {
        existingLock=lockCursor.next();
      }
 else {
        log.warn("String_Node_Str");
        return acquireNextTriggers(noLaterThan,maxCount,timeWindow);
      }
      if (isTriggerLockExpired(existingLock)) {
        log.error("String_Node_Str" + trigger.getKey() + "String_Node_Str");
        removeTriggerLock(trigger);
        return acquireNextTriggers(noLaterThan,maxCount,timeWindow);
      }
    }
  }
  return triggers;
}