Program: 145702
Project: 145702
Buggy source:
/** 
 * Refreshes the columns.
 */
public void refresh(){
  groups.clear();
  heads.clear();
  int cnt=table.getRowCount();
  for (int i=0; i < cnt; i++) {
    table.removeRow(0);
  }
  table.setWidth(cm.getTotalWidth() + "String_Node_Str");
  List<HeaderGroupConfig> configs=cm.getHeaderGroups();
  FlexCellFormatter cf=table.getFlexCellFormatter();
  RowFormatter rf=table.getRowFormatter();
  rows=0;
  for (  HeaderGroupConfig config : configs) {
    rows=Math.max(rows,config.getRow() + 1);
  }
  rows+=1;
  for (int i=0; i < rows; i++) {
    rf.setStyleName(i,styles.headRow());
  }
  int cols=cm.getColumnCount();
  String cellClass=styles.header() + "String_Node_Str" + styles.head();
  for (  HeaderGroupConfig config : cm.getHeaderGroups()) {
    int col=config.getColumn();
    int row=config.getRow();
    int rs=config.getRowspan();
    int cs=config.getColspan();
    Group group=createNewGroup(config);
    boolean hide=true;
    if (rows > 1) {
      for (int i=col; i < (col + cs); i++) {
        if (!cm.isHidden(i)) {
          hide=false;
        }
      }
    }
    if (hide) {
      continue;
    }
    table.setWidget(row,col,group);
    cf.setStyleName(row,col,cellClass);
    HorizontalAlignmentConstant align=config.getHorizontalAlignment();
    cf.setHorizontalAlignment(row,col,align);
    int ncs=cs;
    if (cs > 1) {
      for (int i=col; i < (col + cs); i++) {
        if (cm.isHidden(i)) {
          ncs-=1;
        }
      }
    }
    cf.setRowSpan(row,col,rs);
    cf.setColSpan(row,col,ncs);
  }
  for (int i=0; i < cols; i++) {
    Head h=createNewHead(cm.getColumn(i));
    if (cm.isHidden(i)) {
      continue;
    }
    int rowspan=1;
    if (rows > 1) {
      for (int j=rows - 2; j >= 0; j--) {
        if (!cm.hasGroup(j,i)) {
          rowspan+=1;
        }
      }
    }
    int row;
    if (rowspan > 1) {
      row=(rows - 1) - (rowspan - 1);
    }
 else {
      row=rows - 1;
    }
    h.row=row;
    if (rowspan > 1) {
      table.setWidget(row,i,h);
      table.getFlexCellFormatter().setRowSpan(row,i,rowspan);
    }
 else {
      table.setWidget(row,i,h);
    }
    ColumnConfig<M,?> cc=cm.getColumn(i);
    String s=cc.getColumnClassSuffix() == null ? "String_Node_Str" : "String_Node_Str" + cc.getColumnClassSuffix();
    cf.setStyleName(row,i,cellClass + s);
    cf.getElement(row,i).setPropertyInt("String_Node_Str",i);
    HorizontalAlignmentConstant align=cm.getColumnAlignment(i);
    if (align != null) {
      table.getCellFormatter().setHorizontalAlignment(row,i,align);
      if (align == HasHorizontalAlignment.ALIGN_RIGHT) {
        table.getCellFormatter().getElement(row,i).getFirstChildElement().getStyle().setPropertyPx("String_Node_Str",16);
      }
    }
    updateColumnWidth(i,cm.getColumnWidth(i));
  }
  if (container instanceof Grid) {
    @SuppressWarnings("String_Node_Str") Grid<M> grid=(Grid<M>)container;
    if (grid.getView().isRemoteSort()) {
      List<? extends SortInfo> sortInfos=grid.getLoader().getSortInfo();
      if (sortInfos.size() > 0) {
        SortInfo sortInfo=sortInfos.get(0);
        String sortField=sortInfo.getSortField();
        if (sortField != null && !"String_Node_Str".equals(sortField)) {
          ColumnConfig<M,?> column=cm.findColumnConfig(sortField);
          if (column != null) {
            int index=cm.indexOf(column);
            if (index != -1) {
              updateSortIcon(index,sortInfo.getSortDir());
            }
          }
        }
      }
    }
 else {
      List<StoreSortInfo<M>> sortInfos=grid.getStore().getSortInfo();
      if (sortInfos.size() > 0) {
        StoreSortInfo<M> sortInfo=sortInfos.get(0);
        if (sortInfo != null && sortInfo.getValueProvider() != null) {
          ColumnConfig<M,?> column=grid.getColumnModel().findColumnConfig(sortInfo.getPath());
          if (column != null) {
            updateSortIcon(grid.getColumnModel().indexOf(column),sortInfo.getDirection());
          }
        }
      }
    }
  }
  adjustWidths();
}

Fixed version (ground truth):
/** 
 * Refreshes the columns.
 */
public void refresh(){
  groups.clear();
  heads.clear();
  int cnt=table.getRowCount();
  for (int i=0; i < cnt; i++) {
    table.removeRow(0);
  }
  table.setWidth(cm.getTotalWidth() + "String_Node_Str");
  List<HeaderGroupConfig> configs=cm.getHeaderGroups();
  FlexCellFormatter cf=table.getFlexCellFormatter();
  RowFormatter rf=table.getRowFormatter();
  rows=0;
  for (  HeaderGroupConfig config : configs) {
    rows=Math.max(rows,config.getRow() + 1);
  }
  rows+=1;
  for (int i=0; i < rows; i++) {
    rf.setStyleName(i,styles.headRow());
  }
  int cols=cm.getColumnCount();
  String cellClass=styles.header() + "String_Node_Str" + styles.head();
  for (  HeaderGroupConfig config : cm.getHeaderGroups()) {
    int col=config.getColumn();
    int row=config.getRow();
    int rs=config.getRowspan();
    int cs=config.getColspan();
    Group group=createNewGroup(config);
    boolean hide=true;
    if (rows > 1) {
      for (int i=col; i < (col + cs); i++) {
        if (!cm.isHidden(i)) {
          hide=false;
        }
      }
    }
    if (hide) {
      continue;
    }
    table.setWidget(row,col,group);
    cf.setStyleName(row,col,cellClass);
    HorizontalAlignmentConstant align=config.getHorizontalAlignment();
    cf.setHorizontalAlignment(row,col,align);
    int ncs=cs;
    if (cs > 1) {
      for (int i=col; i < (col + cs); i++) {
        if (cm.isHidden(i)) {
          ncs-=1;
        }
      }
    }
    cf.setRowSpan(row,col,rs);
    cf.setColSpan(row,col,ncs);
  }
  for (int i=0; i < cols; i++) {
    Head h=createNewHead(cm.getColumn(i));
    if (cm.isHidden(i)) {
      continue;
    }
    int rowspan=1;
    if (rows > 1) {
      for (int j=rows - 2; j >= 0; j--) {
        if (!cm.hasGroup(j,i)) {
          rowspan+=1;
        }
      }
    }
    int row;
    if (rowspan > 1) {
      row=(rows - 1) - (rowspan - 1);
    }
 else {
      row=rows - 1;
    }
    h.row=row;
    if (rowspan > 1) {
      table.setWidget(row,i,h);
      table.getFlexCellFormatter().setRowSpan(row,i,rowspan);
    }
 else {
      table.setWidget(row,i,h);
    }
    ColumnConfig<M,?> cc=cm.getColumn(i);
    String s=cc.getColumnClassSuffix() == null ? "String_Node_Str" : "String_Node_Str" + cc.getColumnClassSuffix();
    cf.setStyleName(row,i,cellClass + s);
    cf.getElement(row,i).setPropertyInt("String_Node_Str",i);
    HorizontalAlignmentConstant align=cm.getColumnAlignment(i);
    if (align != null) {
      table.getCellFormatter().setHorizontalAlignment(row,i,align);
      if (align == HasHorizontalAlignment.ALIGN_RIGHT) {
        table.getCellFormatter().getElement(row,i).getFirstChildElement().getStyle().setPropertyPx("String_Node_Str",16);
      }
    }
    h.updateWidth(cm.getColumnWidth(i));
  }
  if (container instanceof Grid) {
    @SuppressWarnings("String_Node_Str") Grid<M> grid=(Grid<M>)container;
    if (grid.getView().isRemoteSort()) {
      List<? extends SortInfo> sortInfos=grid.getLoader().getSortInfo();
      if (sortInfos.size() > 0) {
        SortInfo sortInfo=sortInfos.get(0);
        String sortField=sortInfo.getSortField();
        if (sortField != null && !"String_Node_Str".equals(sortField)) {
          ColumnConfig<M,?> column=cm.findColumnConfig(sortField);
          if (column != null) {
            int index=cm.indexOf(column);
            if (index != -1) {
              updateSortIcon(index,sortInfo.getSortDir());
            }
          }
        }
      }
    }
 else {
      List<StoreSortInfo<M>> sortInfos=grid.getStore().getSortInfo();
      if (sortInfos.size() > 0) {
        StoreSortInfo<M> sortInfo=sortInfos.get(0);
        if (sortInfo != null && sortInfo.getValueProvider() != null) {
          ColumnConfig<M,?> column=grid.getColumnModel().findColumnConfig(sortInfo.getPath());
          if (column != null) {
            updateSortIcon(grid.getColumnModel().indexOf(column),sortInfo.getDirection());
          }
        }
      }
    }
  }
  adjustWidths();
}