Program: 81749
Project: 81749
Buggy source:
/** 
 * Set the row index of the keyboard selected element.
 * @param index the row index
 * @param stealFocus true to steal focus
 * @param forceUpdate force the update even if the row didn't change
 */
public void setKeyboardSelectedRow(int index,boolean stealFocus,boolean forceUpdate){
  if (KeyboardSelectionPolicy.DISABLED == keyboardSelectionPolicy) {
    return;
  }
  if (keyboardPagingPolicy.isLimitedToRange()) {
    index=Math.max(0,Math.min(index,getVisibleItemCount() - 1));
  }
  ensurePendingState().viewTouched=true;
  if (!forceUpdate && getKeyboardSelectedRow() == index && getKeyboardSelectedRowValue() != null) {
    return;
  }
  int pageStart=getPageStart();
  int pageSize=getPageSize();
  int rowCount=getRowCount();
  int absIndex=pageStart + index;
  if (absIndex >= rowCount && isRowCountExact()) {
    absIndex=rowCount - 1;
  }
  index=Math.max(0,absIndex) - pageStart;
  if (keyboardPagingPolicy.isLimitedToRange()) {
    index=Math.max(0,Math.min(index,pageSize - 1));
  }
  int newPageStart=pageStart;
  int newPageSize=pageSize;
  PendingState<T> pending=ensurePendingState();
  pending.keyboardSelectedRow=0;
  pending.keyboardSelectedRowValue=null;
  pending.keyboardSelectedRowChanged=true;
  if (index >= 0 && index < pageSize) {
    pending.keyboardSelectedRow=index;
    pending.keyboardSelectedRowValue=index < pending.getRowDataSize() ? ensurePendingState().getRowDataValue(index) : null;
    pending.keyboardStealFocus=stealFocus;
    return;
  }
 else   if (KeyboardPagingPolicy.CHANGE_PAGE == keyboardPagingPolicy) {
    while (index < 0) {
      newPageStart-=pageSize;
      index+=pageSize;
    }
    while (index >= pageSize) {
      newPageStart+=pageSize;
      index-=pageSize;
    }
  }
 else   if (KeyboardPagingPolicy.INCREASE_RANGE == keyboardPagingPolicy) {
    while (index < 0) {
      newPageSize+=PAGE_INCREMENT;
      newPageStart-=PAGE_INCREMENT;
      index+=PAGE_INCREMENT;
    }
    if (newPageStart < 0) {
      index+=newPageStart;
      newPageSize+=newPageStart;
      newPageStart=0;
    }
    while (index >= newPageSize) {
      newPageSize+=PAGE_INCREMENT;
    }
    if (isRowCountExact()) {
      newPageSize=Math.min(newPageSize,rowCount - newPageStart);
      if (index >= rowCount) {
        index=rowCount - 1;
      }
    }
  }
  if (newPageStart != pageStart || newPageSize != pageSize) {
    pending.keyboardSelectedRow=index;
    setVisibleRange(new Range(newPageStart,newPageSize),false,false);
  }
}

Fixed version (ground truth):
/** 
 * Set the row index of the keyboard selected element.
 * @param index the row index
 * @param stealFocus true to steal focus
 * @param forceUpdate force the update even if the row didn't change
 */
public void setKeyboardSelectedRow(int index,boolean stealFocus,boolean forceUpdate){
  if (KeyboardSelectionPolicy.DISABLED == keyboardSelectionPolicy) {
    return;
  }
  if (keyboardPagingPolicy.isLimitedToRange()) {
    index=Math.max(0,Math.min(index,getVisibleItemCount() - 1));
  }
  ensurePendingState().viewTouched=true;
  if (!forceUpdate && getKeyboardSelectedRow() == index && getKeyboardSelectedRowValue() != null) {
    return;
  }
  int pageStart=getPageStart();
  int pageSize=getPageSize();
  int rowCount=getRowCount();
  int absIndex=pageStart + index;
  if (absIndex >= rowCount && isRowCountExact()) {
    absIndex=rowCount - 1;
  }
  index=Math.max(0,absIndex) - pageStart;
  if (keyboardPagingPolicy.isLimitedToRange()) {
    index=Math.max(0,Math.min(index,pageSize - 1));
  }
  int newPageStart=pageStart;
  int newPageSize=pageSize;
  PendingState<T> pending=ensurePendingState();
  pending.keyboardSelectedRow=0;
  pending.keyboardSelectedRowValue=null;
  pending.keyboardSelectedRowChanged=true;
  if (index >= 0 && index < pageSize) {
    pending.keyboardSelectedRow=index;
    pending.keyboardSelectedRowValue=index < pending.getRowDataSize() ? ensurePendingState().getRowDataValue(index) : null;
    pending.keyboardStealFocus=stealFocus;
    return;
  }
 else   if (KeyboardPagingPolicy.CHANGE_PAGE == keyboardPagingPolicy) {
    while (index < 0) {
      int shift=Math.min(pageSize,newPageStart);
      newPageStart-=shift;
      index+=shift;
    }
    while (index >= pageSize) {
      newPageStart+=pageSize;
      index-=pageSize;
    }
  }
 else   if (KeyboardPagingPolicy.INCREASE_RANGE == keyboardPagingPolicy) {
    while (index < 0) {
      int shift=Math.min(PAGE_INCREMENT,newPageStart);
      newPageSize+=shift;
      newPageStart-=shift;
      index+=shift;
    }
    if (newPageStart < 0) {
      index+=newPageStart;
      newPageSize+=newPageStart;
      newPageStart=0;
    }
    while (index >= newPageSize) {
      newPageSize+=PAGE_INCREMENT;
    }
    if (isRowCountExact()) {
      newPageSize=Math.min(newPageSize,rowCount - newPageStart);
      if (index >= rowCount) {
        index=rowCount - 1;
      }
    }
  }
  if (newPageStart != pageStart || newPageSize != pageSize) {
    pending.keyboardSelectedRow=index;
    setVisibleRange(new Range(newPageStart,newPageSize),false,false);
  }
}