Program: 68410
Project: 68410
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();
        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());
        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) {
      for (int i=1; i <= rsMeta.getColumnCount(); i++) {
        ResultSetColumn rsc=StructureFactory.createResultSetColumn();
        rsc.setColumnName(getColumnName(rsMeta,i));
        if (rsMeta.getColumnType(i) != DataType.ANY_TYPE)         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());
        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;
}