Program: 52451
Project: 52451
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.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());
    int total=getTotalResults();
    List results=null;
    if (total > 0) {
      results=dao.doQuery();
      if (results.size() == 0) {
        offset=total - scope.getResultsPerPage();
        if (offset < 0)         offset=0;
        dao.setOffset(offset);
        results=dao.doQuery();
      }
    }
 else {
      results=new ArrayList();
    }
    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);
  }
}

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());
    int total=getTotalResults(true);
    List results=null;
    if (total > 0) {
      results=dao.doValueQuery();
      if (results.size() == 0) {
        offset=total - scope.getResultsPerPage();
        if (offset < 0)         offset=0;
        dao.setOffset(offset);
        results=dao.doValueQuery();
      }
    }
 else {
      results=new ArrayList();
    }
    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);
  }
}