Program: 3477
Project: 3477
Buggy source:
/** 
 * Browse the archive by single values (such as the name of an author).  This produces a BrowseInfo object that contains Strings as the results of  the browse
 * @param bs		the scope of the browse
 * @return			the results of the browse
 * @throws BrowseException
 */
private BrowseInfo browseByValue(BrowserScope bs) throws BrowseException {
  log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + bs.getJumpToValue()));
  try {
    dao.setTable(browseIndex.getTableName(true,scope.inCommunity(),scope.inCollection()));
    dao.setDistinct(true);
    dao.setAscending(scope.isAscending());
    dao.setJumpToField("String_Node_Str");
    String focusValue=null;
    String rawFocusValue=null;
    if (scope.hasJumpToValue() || scope.hasStartsWith()) {
      focusValue=getJumpToValue();
      rawFocusValue=focusValue;
      focusValue=normalizeJumpToValue(focusValue);
      if (scope.hasStartsWith() && browseIndex.isDate()) {
        focusValue=focusValue + "String_Node_Str";
      }
      dao.setJumpToValue(focusValue);
    }
    if (scope.inCollection() || scope.inCommunity()) {
      dao.setFilterMappingTables(null,browseIndex.getTableName(false,false,false,true));
      if (scope.inCollection()) {
        Collection col=(Collection)scope.getBrowseContainer();
        dao.setContainerTable("String_Node_Str");
        dao.setContainerIDField("String_Node_Str");
        dao.setContainerID(col.getID());
      }
 else       if (scope.inCommunity()) {
        Community com=(Community)scope.getBrowseContainer();
        dao.setContainerTable("String_Node_Str");
        dao.setContainerIDField("String_Node_Str");
        dao.setContainerID(com.getID());
      }
    }
    dao.setOrderField("String_Node_Str");
    dao.setLimit(scope.getResultsPerPage() + 1);
    List results=dao.doValueQuery();
    boolean showLast=false;
    if (results.size() == 0) {
      showLast=true;
    }
    String next=null;
    int lastIndex=results.size() - 1;
    if (lastIndex >= scope.getResultsPerPage()) {
      next=(String)results.get(lastIndex);
      results.remove(lastIndex);
    }
    String prev=null;
    if (scope.hasJumpToValue() || scope.hasStartsWith()) {
      if (showLast) {
        prev=getPreviousPageValue(results);
      }
 else {
        prev=getPreviousPageValue(null);
      }
    }
    int offset=0;
    int total=getTotalResults(true);
    int position=getPosition(true);
    BrowseInfo browseInfo=new BrowseInfo(results,position,total,offset);
    if (next != null) {
      browseInfo.setNextValue(next);
    }
    if (prev != null) {
      browseInfo.setPrevValue(prev);
    }
    browseInfo.setBrowseIndex(browseIndex);
    browseInfo.setSortOption(scope.getSortOption());
    browseInfo.setAscending(scope.isAscending());
    browseInfo.setBrowseLevel(scope.getBrowseLevel());
    browseInfo.setFocus(rawFocusValue);
    browseInfo.setStartsWith(scope.hasStartsWith());
    if (scope.inCollection() || scope.inCommunity()) {
      browseInfo.setBrowseContainer(scope.getBrowseContainer());
    }
    browseInfo.setResultsPerPage(scope.getResultsPerPage());
    return browseInfo;
  }
 catch (  SQLException e) {
    log.error("String_Node_Str",e);
    throw new BrowseException(e);
  }
}

Fixed version (ground truth):
/** 
 * Browse the archive by single values (such as the name of an author).  This produces a BrowseInfo object that contains Strings as the results of the browse
 * @param bs        the scope of the browse
 * @return          the results of the browse
 * @throws BrowseException
 */
private BrowseInfo browseByValue(BrowserScope bs) throws BrowseException {
  log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + bs.getJumpToValue()));
  try {
    dao.setTable(browseIndex.getDistinctTableName());
    dao.setDistinct(true);
    dao.setAscending(scope.isAscending());
    dao.setOrderField("String_Node_Str");
    if (scope.inCollection() || scope.inCommunity()) {
      dao.setFilterMappingTables(null,browseIndex.getMapTableName());
      if (scope.inCollection()) {
        Collection col=(Collection)scope.getBrowseContainer();
        dao.setContainerTable("String_Node_Str");
        dao.setContainerIDField("String_Node_Str");
        dao.setContainerID(col.getID());
      }
 else       if (scope.inCommunity()) {
        Community com=(Community)scope.getBrowseContainer();
        dao.setContainerTable("String_Node_Str");
        dao.setContainerIDField("String_Node_Str");
        dao.setContainerID(com.getID());
      }
    }
    dao.setJumpToField("String_Node_Str");
    int offset=scope.getOffset();
    String rawFocusValue=null;
    if (offset < 1 && scope.hasJumpToValue() || scope.hasStartsWith()) {
      String focusValue=getJumpToValue();
      rawFocusValue=focusValue;
      focusValue=normalizeJumpToValue(focusValue);
      if (scope.hasStartsWith() && browseIndex.isDate()) {
        focusValue=focusValue + "String_Node_Str";
      }
      offset=getOffsetForDistinctValue(focusValue);
    }
    dao.setOffset(offset);
    dao.setLimit(scope.getResultsPerPage());
    List results=dao.doValueQuery();
    int total=getTotalResults(true);
    if (results.size() == 0) {
      offset=total - scope.getResultsPerPage();
      if (offset < 0)       offset=0;
      dao.setOffset(offset);
      results=dao.doQuery();
      total=getTotalResults();
    }
    BrowseInfo browseInfo=new BrowseInfo(results,offset,total,offset);
    if (offset + scope.getResultsPerPage() < total) {
      browseInfo.setNextOffset(offset + scope.getResultsPerPage());
    }
    if (offset - scope.getResultsPerPage() > -1) {
      browseInfo.setPrevOffset(offset - scope.getResultsPerPage());
    }
    browseInfo.setBrowseIndex(browseIndex);
    browseInfo.setSortOption(scope.getSortOption());
    browseInfo.setAscending(scope.isAscending());
    browseInfo.setBrowseLevel(scope.getBrowseLevel());
    browseInfo.setFocus(rawFocusValue);
    browseInfo.setStartsWith(scope.hasStartsWith());
    if (scope.inCollection() || scope.inCommunity()) {
      browseInfo.setBrowseContainer(scope.getBrowseContainer());
    }
    browseInfo.setResultsPerPage(scope.getResultsPerPage());
    return browseInfo;
  }
 catch (  SQLException e) {
    log.error("String_Node_Str",e);
    throw new BrowseException(e);
  }
}