Program: 69844
Project: 69844
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 {
      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();
        rsc.setColumnName(getColumnName(rsMeta,i));
        rsc.setDataType(DataAdapterUtil.adapterToModelDataType(rsMeta.getColumnType(i)));
        rsc.setPosition(new Integer(i));
        columnList.add(rsc);
      }
    }
    if (holdEvent || !dataSetHandle.canEdit()) {
      CompatibilityUtil.updateResultSetinCachedMetaData(dataSetHandle,columnList);
    }
 else {
      if (dataSetHandle.getCachedMetaDataHandle() != null) {
        List resultSetColumnHandles=getResultSetColumnHandles(dataSetHandle.getCachedMetaDataHandle());
        if (resultSetColumnHandles.size() == columnList.size()) {
          for (int i=0; i < resultSetColumnHandles.size(); i++) {
            ResultSetColumnHandle rsh=(ResultSetColumnHandle)resultSetColumnHandles.get(i);
            ResultSetColumn rsc=(ResultSetColumn)columnList.get(i);
            if (!rsh.getColumnName().equals(rsc.getColumnName())) {
              rsh.setColumnName(rsc.getColumnName());
            }
            if (!rsh.getDataType().equals(rsc.getDataType())) {
              rsh.setDataType(rsc.getDataType());
            }
          }
          return rsMeta;
        }
      }
      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) {
      for (int i=1; i <= rsMeta.getColumnCount(); i++) {
        ResultSetColumn rsc=StructureFactory.createResultSetColumn();
        rsc.setColumnName(getColumnName(rsMeta,i));
        rsc.setDataType(DataAdapterUtil.adapterToModelDataType(rsMeta.getColumnType(i)));
        rsc.setPosition(new Integer(i));
        columnList.add(rsc);
      }
    }
    if (holdEvent || !dataSetHandle.canEdit()) {
      CompatibilityUtil.updateResultSetinCachedMetaData(dataSetHandle,columnList);
    }
 else {
      if (dataSetHandle.getCachedMetaDataHandle() != null) {
        List resultSetColumnHandles=getResultSetColumnHandles(dataSetHandle.getCachedMetaDataHandle());
        if (resultSetColumnHandles.size() == columnList.size()) {
          for (int i=0; i < resultSetColumnHandles.size(); i++) {
            ResultSetColumnHandle rsh=(ResultSetColumnHandle)resultSetColumnHandles.get(i);
            ResultSetColumn rsc=(ResultSetColumn)columnList.get(i);
            if (!rsh.getColumnName().equals(rsc.getColumnName())) {
              rsh.setColumnName(rsc.getColumnName());
            }
            if (!rsh.getDataType().equals(rsc.getDataType())) {
              rsh.setDataType(rsc.getDataType());
            }
          }
          return rsMeta;
        }
 else {
          dataSetHandle.getCachedMetaDataHandle().getResultSet().clearValue();
        }
      }
 else {
        dataSetHandle.setCachedMetaData(StructureFactory.createCachedMetaData());
      }
      for (int i=0; i < columnList.size(); i++) {
        dataSetHandle.getCachedMetaDataHandle().getResultSet().addItem((ResultSetColumn)columnList.get(i));
      }
    }
  }
  return rsMeta;
}