Program: 53699
Project: 53699
Buggy source:
/** 
 * Resolve the pending state and push updates to the view.
 */
private void resolvePendingState(){
  pendingStateCommand=null;
  if (pendingState == null) {
    pendingStateLoop=0;
    return;
  }
  pendingStateLoop++;
  if (pendingStateLoop > LOOP_MAXIMUM) {
    pendingStateLoop=0;
    throw new IllegalStateException("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
  }
  if (isResolvingState) {
    throw new IllegalStateException("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
  }
  isResolvingState=true;
  JsArrayInteger modifiedRows=JavaScriptObject.createArray().cast();
  State<T> oldState=state;
  PendingState<T> pending=pendingState;
  int pageStart=pending.getPageStart();
  int pageSize=pending.getPageSize();
  int pageEnd=pageStart + pageSize;
  int rowDataCount=pending.getRowDataSize();
  pending.keyboardSelectedRow=Math.max(0,Math.min(pending.keyboardSelectedRow,rowDataCount - 1));
  if (KeyboardSelectionPolicy.DISABLED == keyboardSelectionPolicy) {
    pending.keyboardSelectedRow=0;
    pending.keyboardSelectedRowValue=null;
  }
 else   if (pending.keyboardSelectedRowChanged) {
    pending.keyboardSelectedRowValue=rowDataCount > 0 ? pending.getRowDataValue(pending.keyboardSelectedRow) : null;
  }
 else   if (pending.keyboardSelectedRowValue != null) {
    int bestMatchIndex=findIndexOfBestMatch(pending,pending.keyboardSelectedRowValue,pending.keyboardSelectedRow);
    if (bestMatchIndex >= 0) {
      pending.keyboardSelectedRow=bestMatchIndex;
      pending.keyboardSelectedRowValue=rowDataCount > 0 ? pending.getRowDataValue(pending.keyboardSelectedRow) : null;
    }
 else {
      pending.keyboardSelectedRow=0;
      pending.keyboardSelectedRowValue=null;
    }
  }
  try {
    if (KeyboardSelectionPolicy.BOUND_TO_SELECTION == keyboardSelectionPolicy && selectionModel != null && pending.viewTouched) {
      T oldValue=oldState.getSelectedValue();
      Object oldKey=getRowValueKey(oldValue);
      T newValue=rowDataCount > 0 ? pending.getRowDataValue(pending.getKeyboardSelectedRow()) : null;
      Object newKey=getRowValueKey(newValue);
      if (newKey != null && !newKey.equals(oldKey)) {
        boolean oldValueWasSelected=(oldValue == null) ? false : selectionModel.isSelected(oldValue);
        boolean newValueWasSelected=(newValue == null) ? false : selectionModel.isSelected(newValue);
        if (oldValueWasSelected) {
          selectionModel.setSelected(oldValue,false);
        }
        pending.selectedValue=newValue;
        if (newValue != null && !newValueWasSelected) {
          selectionModel.setSelected(newValue,true);
        }
      }
    }
  }
 catch (  RuntimeException e) {
    isResolvingState=false;
    throw e;
  }
  boolean keyboardRowChanged=pending.keyboardSelectedRowChanged || (oldState.getKeyboardSelectedRow() != pending.keyboardSelectedRow) || (oldState.getKeyboardSelectedRowValue() == null && pending.keyboardSelectedRowValue != null);
  for (int i=pageStart; i < pageStart + rowDataCount; i++) {
    T rowValue=pending.getRowDataValue(i - pageStart);
    boolean isSelected=(rowValue != null && selectionModel != null && selectionModel.isSelected(rowValue));
    boolean wasSelected=oldState.isRowSelected(i);
    if (isSelected) {
      pending.selectedRows.add(i);
      if (!wasSelected) {
        modifiedRows.push(i);
      }
    }
 else     if (wasSelected) {
      modifiedRows.push(i);
    }
  }
  if (pendingStateCommand != null) {
    isResolvingState=false;
    return;
  }
  pendingStateLoop=0;
  state=pendingState;
  pendingState=null;
  boolean replacedEmptyRange=false;
  for (  Range replacedRange : pending.replacedRanges) {
    int start=replacedRange.getStart();
    int length=replacedRange.getLength();
    if (length == 0) {
      replacedEmptyRange=true;
    }
    for (int i=start; i < start + length; i++) {
      modifiedRows.push(i);
    }
  }
  if (modifiedRows.length() > 0 && keyboardRowChanged) {
    modifiedRows.push(oldState.getKeyboardSelectedRow());
    modifiedRows.push(pending.keyboardSelectedRow);
  }
  List<Range> modifiedRanges=calculateModifiedRanges(modifiedRows,pageStart,pageEnd);
  Range range0=modifiedRanges.size() > 0 ? modifiedRanges.get(0) : null;
  Range range1=modifiedRanges.size() > 1 ? modifiedRanges.get(1) : null;
  int replaceDiff=0;
  for (  Range range : modifiedRanges) {
    replaceDiff+=range.getLength();
  }
  int oldPageStart=oldState.getPageStart();
  int oldPageSize=oldState.getPageSize();
  int oldRowDataCount=oldState.getRowDataSize();
  boolean redrawRequired=pending.redrawRequired;
  if (pageStart != oldPageStart) {
    redrawRequired=true;
  }
 else   if (rowDataCount < oldRowDataCount) {
    redrawRequired=true;
  }
 else   if (range1 == null && range0 != null && range0.getStart() == pageStart && (replaceDiff >= oldRowDataCount || replaceDiff > oldPageSize)) {
    redrawRequired=true;
  }
 else   if (replaceDiff >= REDRAW_MINIMUM && replaceDiff > REDRAW_THRESHOLD * oldRowDataCount) {
    redrawRequired=true;
  }
 else   if (replacedEmptyRange && oldRowDataCount == 0) {
    redrawRequired=true;
  }
  updateLoadingState();
  try {
    if (redrawRequired) {
      SafeHtmlBuilder sb=new SafeHtmlBuilder();
      view.replaceAllChildren(pending.rowData,selectionModel,pending.keyboardStealFocus);
      view.resetFocus();
    }
 else     if (range0 != null) {
{
        int absStart=range0.getStart();
        int relStart=absStart - pageStart;
        SafeHtmlBuilder sb=new SafeHtmlBuilder();
        List<T> replaceValues=pending.rowData.subList(relStart,relStart + range0.getLength());
        view.replaceChildren(replaceValues,relStart,selectionModel,pending.keyboardStealFocus);
      }
      if (range1 != null) {
        int absStart=range1.getStart();
        int relStart=absStart - pageStart;
        SafeHtmlBuilder sb=new SafeHtmlBuilder();
        List<T> replaceValues=pending.rowData.subList(relStart,relStart + range1.getLength());
        view.replaceChildren(replaceValues,relStart,selectionModel,pending.keyboardStealFocus);
      }
      view.resetFocus();
    }
 else     if (keyboardRowChanged) {
      int oldSelectedRow=oldState.getKeyboardSelectedRow();
      if (oldSelectedRow >= 0 && oldSelectedRow < rowDataCount) {
        view.setKeyboardSelected(oldSelectedRow,false,false);
      }
      int newSelectedRow=pending.getKeyboardSelectedRow();
      if (newSelectedRow >= 0 && newSelectedRow < rowDataCount) {
        view.setKeyboardSelected(newSelectedRow,true,pending.keyboardStealFocus);
      }
    }
  }
 catch (  Error e) {
    throw new RuntimeException(e);
  }
 finally {
    isResolvingState=false;
  }
}

Fixed version (ground truth):
/** 
 * Resolve the pending state and push updates to the view.
 */
private void resolvePendingState(){
  pendingStateCommand=null;
  if (pendingState == null) {
    pendingStateLoop=0;
    return;
  }
  pendingStateLoop++;
  if (pendingStateLoop > LOOP_MAXIMUM) {
    pendingStateLoop=0;
    throw new IllegalStateException("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
  }
  if (isResolvingState) {
    throw new IllegalStateException("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
  }
  isResolvingState=true;
  JsArrayInteger modifiedRows=JavaScriptObject.createArray().cast();
  State<T> oldState=state;
  PendingState<T> pending=pendingState;
  int pageStart=pending.getPageStart();
  int pageSize=pending.getPageSize();
  int pageEnd=pageStart + pageSize;
  int rowDataCount=pending.getRowDataSize();
  pending.keyboardSelectedRow=Math.max(0,Math.min(pending.keyboardSelectedRow,rowDataCount - 1));
  if (KeyboardSelectionPolicy.DISABLED == keyboardSelectionPolicy) {
    pending.keyboardSelectedRow=0;
    pending.keyboardSelectedRowValue=null;
  }
 else   if (pending.keyboardSelectedRowChanged) {
    pending.keyboardSelectedRowValue=rowDataCount > 0 ? pending.getRowDataValue(pending.keyboardSelectedRow) : null;
  }
 else   if (pending.keyboardSelectedRowValue != null) {
    int bestMatchIndex=findIndexOfBestMatch(pending,pending.keyboardSelectedRowValue,pending.keyboardSelectedRow);
    if (bestMatchIndex >= 0) {
      pending.keyboardSelectedRow=bestMatchIndex;
      pending.keyboardSelectedRowValue=rowDataCount > 0 ? pending.getRowDataValue(pending.keyboardSelectedRow) : null;
    }
 else {
      pending.keyboardSelectedRow=0;
      pending.keyboardSelectedRowValue=null;
    }
  }
  try {
    if (KeyboardSelectionPolicy.BOUND_TO_SELECTION == keyboardSelectionPolicy && selectionModel != null && pending.viewTouched) {
      T oldValue=oldState.getSelectedValue();
      Object oldKey=getRowValueKey(oldValue);
      T newValue=rowDataCount > 0 ? pending.getRowDataValue(pending.getKeyboardSelectedRow()) : null;
      Object newKey=getRowValueKey(newValue);
      if (newKey != null) {
        boolean oldValueWasSelected=(oldValue == null) ? false : selectionModel.isSelected(oldValue);
        boolean newValueWasSelected=(newValue == null) ? false : selectionModel.isSelected(newValue);
        if (!newKey.equals(oldKey)) {
          if (oldValueWasSelected) {
            selectionModel.setSelected(oldValue,false);
          }
          pending.selectedValue=newValue;
          if (newValue != null && !newValueWasSelected) {
            selectionModel.setSelected(newValue,true);
          }
        }
 else         if (!newValueWasSelected) {
          pending.selectedValue=null;
        }
      }
    }
  }
 catch (  RuntimeException e) {
    isResolvingState=false;
    throw e;
  }
  boolean keyboardRowChanged=pending.keyboardSelectedRowChanged || (oldState.getKeyboardSelectedRow() != pending.keyboardSelectedRow) || (oldState.getKeyboardSelectedRowValue() == null && pending.keyboardSelectedRowValue != null);
  for (int i=pageStart; i < pageStart + rowDataCount; i++) {
    T rowValue=pending.getRowDataValue(i - pageStart);
    boolean isSelected=(rowValue != null && selectionModel != null && selectionModel.isSelected(rowValue));
    boolean wasSelected=oldState.isRowSelected(i);
    if (isSelected) {
      pending.selectedRows.add(i);
      if (!wasSelected) {
        modifiedRows.push(i);
      }
    }
 else     if (wasSelected) {
      modifiedRows.push(i);
    }
  }
  if (pendingStateCommand != null) {
    isResolvingState=false;
    return;
  }
  pendingStateLoop=0;
  state=pendingState;
  pendingState=null;
  boolean replacedEmptyRange=false;
  for (  Range replacedRange : pending.replacedRanges) {
    int start=replacedRange.getStart();
    int length=replacedRange.getLength();
    if (length == 0) {
      replacedEmptyRange=true;
    }
    for (int i=start; i < start + length; i++) {
      modifiedRows.push(i);
    }
  }
  if (modifiedRows.length() > 0 && keyboardRowChanged) {
    modifiedRows.push(oldState.getKeyboardSelectedRow());
    modifiedRows.push(pending.keyboardSelectedRow);
  }
  List<Range> modifiedRanges=calculateModifiedRanges(modifiedRows,pageStart,pageEnd);
  Range range0=modifiedRanges.size() > 0 ? modifiedRanges.get(0) : null;
  Range range1=modifiedRanges.size() > 1 ? modifiedRanges.get(1) : null;
  int replaceDiff=0;
  for (  Range range : modifiedRanges) {
    replaceDiff+=range.getLength();
  }
  int oldPageStart=oldState.getPageStart();
  int oldPageSize=oldState.getPageSize();
  int oldRowDataCount=oldState.getRowDataSize();
  boolean redrawRequired=pending.redrawRequired;
  if (pageStart != oldPageStart) {
    redrawRequired=true;
  }
 else   if (rowDataCount < oldRowDataCount) {
    redrawRequired=true;
  }
 else   if (range1 == null && range0 != null && range0.getStart() == pageStart && (replaceDiff >= oldRowDataCount || replaceDiff > oldPageSize)) {
    redrawRequired=true;
  }
 else   if (replaceDiff >= REDRAW_MINIMUM && replaceDiff > REDRAW_THRESHOLD * oldRowDataCount) {
    redrawRequired=true;
  }
 else   if (replacedEmptyRange && oldRowDataCount == 0) {
    redrawRequired=true;
  }
  updateLoadingState();
  try {
    if (redrawRequired) {
      SafeHtmlBuilder sb=new SafeHtmlBuilder();
      view.replaceAllChildren(pending.rowData,selectionModel,pending.keyboardStealFocus);
      view.resetFocus();
    }
 else     if (range0 != null) {
{
        int absStart=range0.getStart();
        int relStart=absStart - pageStart;
        SafeHtmlBuilder sb=new SafeHtmlBuilder();
        List<T> replaceValues=pending.rowData.subList(relStart,relStart + range0.getLength());
        view.replaceChildren(replaceValues,relStart,selectionModel,pending.keyboardStealFocus);
      }
      if (range1 != null) {
        int absStart=range1.getStart();
        int relStart=absStart - pageStart;
        SafeHtmlBuilder sb=new SafeHtmlBuilder();
        List<T> replaceValues=pending.rowData.subList(relStart,relStart + range1.getLength());
        view.replaceChildren(replaceValues,relStart,selectionModel,pending.keyboardStealFocus);
      }
      view.resetFocus();
    }
 else     if (keyboardRowChanged) {
      int oldSelectedRow=oldState.getKeyboardSelectedRow();
      if (oldSelectedRow >= 0 && oldSelectedRow < rowDataCount) {
        view.setKeyboardSelected(oldSelectedRow,false,false);
      }
      int newSelectedRow=pending.getKeyboardSelectedRow();
      if (newSelectedRow >= 0 && newSelectedRow < rowDataCount) {
        view.setKeyboardSelected(newSelectedRow,true,pending.keyboardStealFocus);
      }
    }
  }
 catch (  Error e) {
    throw new RuntimeException(e);
  }
 finally {
    isResolvingState=false;
  }
}