Program: 52417
Project: 52417
Buggy source:
/** 
 * Get the value (for single value browses) for the result that appears at the top of the previous page, for when the User Interface is performing result set paging. The callback argument allows for this method to populate the List with the results obtained from the query, which can be useful when, for example, reaching the final browse page and needing additional results to pad up to the number of results per page
 * @param callback		A List object for holding String objects indexed numerically in the correct order
 * @return				the value of the top of the previous page
 * @throws SQLException
 * @throws BrowseException
 */
private String getPreviousPageValue(List callback) throws SQLException, BrowseException {
  boolean capture=false;
  if (callback != null) {
    capture=true;
  }
  log.debug(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + capture));
  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.doValueQuery();
  dao.setAscending(isAscending);
  dao.setEqualsComparator(useEquals);
  dao.setLimit(resultLimit);
  Iterator itr=results.iterator();
  int i=0;
  String prev=null;
  while (itr.hasNext()) {
    String value=(String)itr.next();
    prev=value;
    if (capture && i < scope.getResultsPerPage()) {
      callback.add(0,value);
      i++;
    }
  }
  log.debug(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + prev));
  return prev;
}

Fixed version (ground truth):
/** 
 * Get the value (for single value browses) for the result that appears at the top of the previous page, for when the User Interface is performing result set paging. The callback argument allows for this method to populate the List with the results obtained from the query, which can be useful when, for example, reaching the final browse page and needing additional results to pad up to the number of results per page
 * @param callback      A List object for holding String objects indexed numerically in the correct order
 * @return              the value of the top of the previous page
 * @throws SQLException
 * @throws BrowseException
 */
private String getPreviousPageValue(List callback) throws SQLException, BrowseException {
  boolean capture=false;
  if (callback != null) {
    capture=true;
  }
  log.debug(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + capture));
  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.doValueQuery();
  dao.setAscending(isAscending);
  dao.setEqualsComparator(useEquals);
  dao.setLimit(resultLimit);
  Iterator itr=results.iterator();
  int i=0;
  String prev=null;
  while (itr.hasNext()) {
    String value=(String)itr.next();
    prev=value;
    if (capture && i < scope.getResultsPerPage()) {
      callback.add(0,value);
      i++;
    }
  }
  log.debug(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + prev));
  return prev;
}