Program: 50611
Project: 50611
Buggy source:
@Override public BuildRepositoryChanges collectChangesSinceLastBuild(String planKey,String lastVcsRevisionKey) throws RepositoryException {
  final BuildLogger buildLogger=buildLoggerManager.getLogger(PlanKeys.getPlanKey(planKey));
  List<Commit> commits=new ArrayList<Commit>();
  GerritChangeVO change=null;
  if (this.getVcsBranch().equals(DEFAULT_BRANCH)) {
    change=getGerritDAO().getLastUnverifiedChange(project);
    if (change == null) {
      change=getGerritDAO().getLastChange(project);
    }
  }
 else {
    change=getGerritDAO().getLastUnverifiedChange(project,this.getVcsBranch().getName());
    if (change == null) {
      change=getGerritDAO().getLastChange(project,this.getVcsBranch().getName());
    }
  }
  log.debug(String.format("String_Node_Str",change.getBranch(),change.getId(),change.getCurrentPatchSet().getRef()));
  buildLogger.addBuildLogEntry(textProvider.getText("String_Node_Str"));
  if ((change == null) && ((lastVcsRevisionKey == null) || lastVcsRevisionKey.isEmpty())) {
    throw new RepositoryException(textProvider.getText("String_Node_Str"));
  }
 else   if (lastVcsRevisionKey == null) {
    buildLogger.addBuildLogEntry(textProvider.getText("String_Node_Str",Arrays.asList(change.getLastRevision())));
  }
 else   if (change.getLastRevision().equals(lastVcsRevisionKey)) {
    Object lastRevForChange=bandanaManager.getValue(PlanAwareBandanaContext.GLOBAL_CONTEXT,change.getId());
    if ((lastRevForChange != null) && lastRevForChange.equals(change.getLastRevision()))     return new BuildRepositoryChangesImpl(change.getLastRevision());
  }
  commits.add(convertChangeToCommit(change,true));
  BuildRepositoryChanges buildChanges=new BuildRepositoryChangesImpl(change.getLastRevision(),commits);
  bandanaManager.setValue(PlanAwareBandanaContext.GLOBAL_CONTEXT,change.getId(),change.getLastRevision());
  return buildChanges;
}

Fixed version (ground truth):
@Override public BuildRepositoryChanges collectChangesSinceLastBuild(String planKey,String lastVcsRevisionKey) throws RepositoryException {
  final BuildLogger buildLogger=buildLoggerManager.getLogger(PlanKeys.getPlanKey(planKey));
  List<Commit> commits=new ArrayList<Commit>();
  GerritChangeVO change=null;
  if (this.getVcsBranch().equals(ALL_BRANCH)) {
    change=getGerritDAO().getLastUnverifiedChange(project);
    if (change == null) {
      change=getGerritDAO().getLastChange(project);
    }
  }
 else {
    change=getGerritDAO().getLastUnverifiedChange(project,this.getVcsBranch().getName());
    if (change == null) {
      change=getGerritDAO().getLastChange(project,this.getVcsBranch().getName());
    }
  }
  log.debug(String.format("String_Node_Str",change.getBranch(),change.getId(),change.getCurrentPatchSet().getRef()));
  buildLogger.addBuildLogEntry(textProvider.getText("String_Node_Str"));
  if ((change == null) && ((lastVcsRevisionKey == null) || lastVcsRevisionKey.isEmpty())) {
    throw new RepositoryException(textProvider.getText("String_Node_Str"));
  }
 else   if (lastVcsRevisionKey == null) {
    buildLogger.addBuildLogEntry(textProvider.getText("String_Node_Str",Arrays.asList(change.getLastRevision())));
  }
 else   if (change.getLastRevision().equals(lastVcsRevisionKey)) {
    Object lastRevForChange=bandanaManager.getValue(PlanAwareBandanaContext.GLOBAL_CONTEXT,change.getId());
    if ((lastRevForChange != null) && lastRevForChange.equals(change.getLastRevision()))     return new BuildRepositoryChangesImpl(change.getLastRevision());
  }
  commits.add(convertChangeToCommit(change,true));
  BuildRepositoryChanges buildChanges=new BuildRepositoryChangesImpl(change.getLastRevision(),commits);
  bandanaManager.setValue(PlanAwareBandanaContext.GLOBAL_CONTEXT,change.getId(),change.getLastRevision());
  return buildChanges;
}