Program: 52416
Project: 52416
Buggy source:
/** 
 * Get the database id of the item at the top of what will be the previous page of results.  This is so that a "back" button can be generated by the User Interface when paging through results.  The callback argument is there so that if the caller wishes the actual results from the previous page can also be returned (this is useful, for example, if you are on the very last page of results, and need some previous results to pad out the full number of results per page).  If the callback is null, then no results are kept
 * @param callback	A List object for holding BrowseItem objects indexed numerically in the correct order
 * @return			the database id of the top of the previous page
 * @throws SQLException
 * @throws BrowseException
 */
private int getPreviousPageID(List callback) throws SQLException, BrowseException {
  log.debug(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"));
  boolean capture=false;
  if (callback != null) {
    capture=true;
  }
  boolean isAscending=dao.isAscending();
  dao.setAscending(!isAscending);
  boolean useEquals=dao.useEqualsComparator();
  dao.setEqualsComparator(false);
  int resultLimit=dao.getLimit();
  int limit=scope.getResultsPerPage();
  if (capture) {
    limit*=2;
  }
  dao.setLimit(limit);
  List results=dao.doQuery();
  dao.setAscending(isAscending);
  dao.setEqualsComparator(useEquals);
  dao.setLimit(resultLimit);
  Iterator itr=results.iterator();
  int i=0;
  BrowseItem prev=null;
  while (itr.hasNext()) {
    BrowseItem browseItem=(BrowseItem)itr.next();
    prev=browseItem;
    if (capture && i < scope.getResultsPerPage()) {
      callback.add(0,browseItem);
      i++;
    }
  }
  if (prev != null) {
    return prev.getID();
  }
 else {
    return -1;
  }
}

Fixed version (ground truth):
/** 
 * Get the database id of the item at the top of what will be the previous page of results.  This is so that a "back" button can be generated by the User Interface when paging through results.  The callback argument is there so that if the caller wishes the actual results from the previous page can also be returned (this is useful, for example, if you are on the very last page of results, and need some previous results to pad out the full number of results per page).  If the callback is null, then no results are kept
 * @param callback  A List object for holding BrowseItem objects indexed numerically in the correct order
 * @return          the database id of the top of the previous page
 * @throws SQLException
 * @throws BrowseException
 */
private int getPreviousPageID(List callback) throws SQLException, BrowseException {
  log.debug(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"));
  boolean capture=false;
  if (callback != null) {
    capture=true;
  }
  boolean isAscending=dao.isAscending();
  dao.setAscending(!isAscending);
  boolean useEquals=dao.useEqualsComparator();
  dao.setEqualsComparator(false);
  int resultLimit=dao.getLimit();
  int limit=scope.getResultsPerPage();
  if (capture) {
    limit*=2;
  }
  dao.setLimit(limit);
  List results=dao.doQuery();
  dao.setAscending(isAscending);
  dao.setEqualsComparator(useEquals);
  dao.setLimit(resultLimit);
  Iterator itr=results.iterator();
  int i=0;
  BrowseItem prev=null;
  while (itr.hasNext()) {
    BrowseItem browseItem=(BrowseItem)itr.next();
    prev=browseItem;
    if (capture && i < scope.getResultsPerPage()) {
      callback.add(0,browseItem);
      i++;
    }
  }
  if (prev != null) {
    return prev.getID();
  }
 else {
    return -1;
  }
}