Program: 65131
Project: 65131
Buggy source:
/** 
 * @param dataSetHandle
 * @return
 * @throws BirtException
 */
IResultMetaData refreshMetaData(DataSetHandle dataSetHandle,boolean holdEvent) throws BirtException {
  IResultMetaData rsMeta=null;
  try {
    rsMeta=this.getDataSetMetaData(dataSetHandle,false);
  }
 catch (  BirtException e1) {
    if (holdEvent || !dataSetHandle.canEdit()) {
      CompatibilityUtil.updateResultSetinCachedMetaData(dataSetHandle,new ArrayList());
    }
 else {
      if (dataSetHandle.getCachedMetaDataHandle() != null)       dataSetHandle.getCachedMetaDataHandle().getResultSet().clearValue();
 else       dataSetHandle.setCachedMetaData(StructureFactory.createCachedMetaData());
    }
    throw e1;
  }
  if (needsSetCachedMetaData(dataSetHandle,rsMeta)) {
    List columnList=new ArrayList();
    if (rsMeta != null && rsMeta.getColumnCount() != 0) {
      for (int i=1; i <= rsMeta.getColumnCount(); i++) {
        ResultSetColumn rsc=StructureFactory.createResultSetColumn();
        String columnName=getColumnName(rsMeta,i);
        if (columnName == null || columnName.trim().length() == 0) {
          List list=dataSetHandle.getListProperty(IDataSetModel.RESULT_SET_PROP);
          ResultSetColumn column=(ResultSetColumn)list.get(i - 1);
          rsc.setColumnName(column.getColumnName());
        }
 else {
          rsc.setColumnName(columnName);
        }
        if (rsMeta.getColumnType(i) != DataType.ANY_TYPE)         rsc.setDataType(DataAdapterUtil.adapterToModelDataType(rsMeta.getColumnType(i)));
        rsc.setPosition(Integer.valueOf(i));
        columnList.add(rsc);
      }
    }
    if (holdEvent || !dataSetHandle.canEdit()) {
      CompatibilityUtil.updateResultSetinCachedMetaData(dataSetHandle,columnList);
    }
 else {
      if (dataSetHandle.getCachedMetaDataHandle() != null) {
        List resultSetColumnHandles=getResultSetColumnHandles(dataSetHandle.getCachedMetaDataHandle());
        int i=0;
        for (; i < columnList.size(); i++) {
          ResultSetColumn rsc=(ResultSetColumn)columnList.get(i);
          if (i < resultSetColumnHandles.size()) {
            ResultSetColumnHandle rsh=(ResultSetColumnHandle)resultSetColumnHandles.get(i);
            if (!rsh.getColumnName().equals(rsc.getColumnName())) {
              rsh.setColumnName(rsc.getColumnName());
            }
            if (!rsh.getDataType().equals(rsc.getDataType())) {
              rsh.setDataType(rsc.getDataType());
            }
          }
 else {
            dataSetHandle.getCachedMetaDataHandle().getResultSet().addItem(rsc);
          }
        }
        if (i < resultSetColumnHandles.size()) {
          List toRemoved=resultSetColumnHandles.subList(i,resultSetColumnHandles.size());
          dataSetHandle.getCachedMetaDataHandle().getResultSet().removeItems(toRemoved);
        }
      }
 else {
        dataSetHandle.setCachedMetaData(StructureFactory.createCachedMetaData());
        for (int i=0; i < columnList.size(); i++) {
          dataSetHandle.getCachedMetaDataHandle().getResultSet().addItem((ResultSetColumn)columnList.get(i));
        }
      }
    }
  }
  return rsMeta;
}

Fixed version (ground truth):
/** 
 * @param dataSetHandle
 * @return
 * @throws BirtException
 */
IResultMetaData refreshMetaData(DataSetHandle dataSetHandle,boolean holdEvent) throws BirtException {
  IResultMetaData rsMeta=null;
  try {
    rsMeta=this.getDataSetMetaData(dataSetHandle,false);
  }
 catch (  BirtException e1) {
    if (holdEvent || !dataSetHandle.canEdit()) {
      CompatibilityUtil.updateResultSetinCachedMetaData(dataSetHandle,new ArrayList());
    }
 else {
      if (dataSetHandle.getCachedMetaDataHandle() != null)       dataSetHandle.getCachedMetaDataHandle().getResultSet().clearValue();
 else       dataSetHandle.setCachedMetaData(StructureFactory.createCachedMetaData());
    }
    throw e1;
  }
  if (needsSetCachedMetaData(dataSetHandle,rsMeta)) {
    List columnList=new ArrayList();
    if (rsMeta != null && rsMeta.getColumnCount() != 0) {
      PropertyHandle columnHintList=dataSetHandle.getPropertyHandle(DataSetHandle.COLUMN_HINTS_PROP);
      for (int i=1; i <= rsMeta.getColumnCount(); i++) {
        ResultSetColumn rsc=StructureFactory.createResultSetColumn();
        String columnName=null;
        ColumnHintHandle matchedColumnHint=findColumnHint(rsMeta.getColumnName(i),columnHintList);
        if (matchedColumnHint != null) {
          String rsAlias=rsMeta.getColumnAlias(i);
          if (rsAlias != null) {
            updateColumnHintValues(rsAlias,matchedColumnHint);
          }
          columnName=matchedColumnHint.getAlias();
        }
        if (columnName == null || columnName.trim().length() == 0) {
          columnName=getColumnName(rsMeta,i);
        }
        if (columnName == null || columnName.trim().length() == 0) {
          List list=dataSetHandle.getListProperty(IDataSetModel.RESULT_SET_PROP);
          ResultSetColumn column=(ResultSetColumn)list.get(i - 1);
          rsc.setColumnName(column.getColumnName());
        }
 else {
          rsc.setColumnName(columnName);
        }
        if (rsMeta.getColumnType(i) != DataType.ANY_TYPE)         rsc.setDataType(DataAdapterUtil.adapterToModelDataType(rsMeta.getColumnType(i)));
        rsc.setPosition(Integer.valueOf(i));
        columnList.add(rsc);
      }
    }
    if (holdEvent || !dataSetHandle.canEdit()) {
      CompatibilityUtil.updateResultSetinCachedMetaData(dataSetHandle,columnList);
    }
 else {
      if (dataSetHandle.getCachedMetaDataHandle() != null) {
        List resultSetColumnHandles=getResultSetColumnHandles(dataSetHandle.getCachedMetaDataHandle());
        int i=0;
        for (; i < columnList.size(); i++) {
          ResultSetColumn rsc=(ResultSetColumn)columnList.get(i);
          if (i < resultSetColumnHandles.size()) {
            ResultSetColumnHandle rsh=(ResultSetColumnHandle)resultSetColumnHandles.get(i);
            if (!rsh.getColumnName().equals(rsc.getColumnName())) {
              rsh.setColumnName(rsc.getColumnName());
            }
            if (!rsh.getDataType().equals(rsc.getDataType())) {
              rsh.setDataType(rsc.getDataType());
            }
          }
 else {
            dataSetHandle.getCachedMetaDataHandle().getResultSet().addItem(rsc);
          }
        }
        if (i < resultSetColumnHandles.size()) {
          List toRemoved=resultSetColumnHandles.subList(i,resultSetColumnHandles.size());
          dataSetHandle.getCachedMetaDataHandle().getResultSet().removeItems(toRemoved);
        }
      }
 else {
        dataSetHandle.setCachedMetaData(StructureFactory.createCachedMetaData());
        for (int i=0; i < columnList.size(); i++) {
          dataSetHandle.getCachedMetaDataHandle().getResultSet().addItem((ResultSetColumn)columnList.get(i));
        }
      }
    }
  }
  return rsMeta;
}