Program: 68367
Project: 68367
Buggy source:
private static void cloneEdgeDefinition(ICubeQueryDefinition cloneQuery,IEdgeDefinition edge,int type,IEdgeDrillFilter drill,ICube cube) throws DataException {
  IEdgeDefinition cloneEdge=cloneQuery.createEdge(type);
  Iterator<IDimensionDefinition> dimension=edge.getDimensions().iterator();
  List<ILevelDefinition> levelDefnList=new ArrayList<ILevelDefinition>();
  while (dimension.hasNext()) {
    IDimensionDefinition dim=(IDimensionDefinition)dimension.next();
    IDimensionDefinition cloneDim=cloneEdge.createDimension(dim.getName());
    Iterator<IHierarchyDefinition> hierarchyIter=dim.getHierarchy().iterator();
    while (hierarchyIter.hasNext()) {
      IHierarchyDefinition hierarchy=(IHierarchyDefinition)hierarchyIter.next();
      IHierarchyDefinition cloneHier=cloneDim.createHierarchy(hierarchy.getName());
      if (drill != null && hierarchy.getName().equals(drill.getTargetHierarchy().getName())) {
{
          IHierarchy cubeHierarchy=findHierarchyFromCube(cube,hierarchy);
          for (          ILevel cubeLevel : cubeHierarchy.getLevels()) {
            ILevelDefinition cloneLevel;
            if (cubeLevel.getName().equals(drill.getTargetLevelName())) {
              cloneLevel=cloneHier.createLevel(cubeLevel.getName());
              levelDefnList.add(cloneLevel);
              break;
            }
            cloneLevel=cloneHier.createLevel(cubeLevel.getName());
            levelDefnList.add(cloneLevel);
          }
        }
      }
 else {
        Iterator<ILevelDefinition> levels=hierarchy.getLevels().iterator();
        while (levels.hasNext()) {
          ILevelDefinition level=(ILevelDefinition)levels.next();
          ILevelDefinition cloneLevel=cloneHier.createLevel(level.getName());
          levelDefnList.add(cloneLevel);
        }
      }
    }
  }
  if (drill != null) {
    Iterator members=drill.getTuple().iterator();
    Iterator levels=levelDefnList.iterator();
    while (members.hasNext() && levels.hasNext()) {
      Object[] key=(Object[])members.next();
      if (key != null && key.length > 0 && key[0] != null) {
        Object[][] multipleKey=new Object[key.length][];
        for (int i=0; i < key.length; i++) {
          multipleKey[i]=new Object[]{key[i]};
        }
        ISelection selection=SelectionFactory.createMutiKeySelection(multipleKey);
        ((DrillCubeQueryDefinition)cloneQuery).addLevelFilter(new LevelFilter(new DimLevel((ILevelDefinition)levels.next()),new ISelection[]{selection}));
      }
    }
  }
}

Fixed version (ground truth):
private static void cloneEdgeDefinition(DrillCubeQueryDefinition cloneQuery,IEdgeDefinition edge,int type,IEdgeDrillFilter drill,ICube cube) throws DataException {
  IEdgeDefinition cloneEdge=cloneQuery.createEdge(type);
  Iterator<IDimensionDefinition> dimension=edge.getDimensions().iterator();
  List<ILevelDefinition> levelDefnList=new ArrayList<ILevelDefinition>();
  while (dimension.hasNext()) {
    IDimensionDefinition dim=(IDimensionDefinition)dimension.next();
    IDimensionDefinition cloneDim=cloneEdge.createDimension(dim.getName());
    Iterator<IHierarchyDefinition> hierarchyIter=dim.getHierarchy().iterator();
    while (hierarchyIter.hasNext()) {
      IHierarchyDefinition hierarchy=(IHierarchyDefinition)hierarchyIter.next();
      IHierarchyDefinition cloneHier=cloneDim.createHierarchy(hierarchy.getName());
      if (drill != null && hierarchy.getName().equals(drill.getTargetHierarchy().getName())) {
{
          IHierarchy cubeHierarchy=findHierarchyFromCube(cube,hierarchy);
          for (          ILevel cubeLevel : cubeHierarchy.getLevels()) {
            ILevelDefinition cloneLevel;
            if (cubeLevel.getName().equals(drill.getTargetLevelName())) {
              cloneLevel=cloneHier.createLevel(cubeLevel.getName());
              levelDefnList.add(cloneLevel);
              break;
            }
            cloneLevel=cloneHier.createLevel(cubeLevel.getName());
            levelDefnList.add(cloneLevel);
          }
        }
      }
 else {
        Iterator<ILevelDefinition> levels=hierarchy.getLevels().iterator();
        while (levels.hasNext()) {
          ILevelDefinition level=(ILevelDefinition)levels.next();
          ILevelDefinition cloneLevel=cloneHier.createLevel(level.getName());
          levelDefnList.add(cloneLevel);
        }
      }
    }
  }
  if (drill != null) {
    Iterator members=drill.getTuple().iterator();
    Iterator levels=levelDefnList.iterator();
    Collection<Object[]> qulifiedTuple=new ArrayList<Object[]>();
    while (members.hasNext() && levels.hasNext()) {
      Object[] key=(Object[])members.next();
      if (key != null && key.length > 0 && key[0] != null) {
        ILevelDefinition level=(ILevelDefinition)levels.next();
        int dataType=getLevelDataType(level,cube);
        Object[] qualifiedKey=new Object[key.length];
        Object[][] multipleKey=new Object[key.length][];
        for (int i=0; i < key.length; i++) {
          try {
            Object value=DataTypeUtil.convert(key[i],dataType);
            qualifiedKey[i]=value;
            multipleKey[i]=new Object[]{value};
          }
 catch (          BirtException e) {
          }
        }
        qulifiedTuple.add(qualifiedKey);
        ISelection selection=SelectionFactory.createMutiKeySelection(multipleKey);
        ((DrillCubeQueryDefinition)cloneQuery).addLevelFilter(new LevelFilter(new DimLevel((ILevelDefinition)level),new ISelection[]{selection}));
      }
    }
    if (type == ICubeQueryDefinition.COLUMN_EDGE)     cloneQuery.setTupleOnColumn(qulifiedTuple);
 else     cloneQuery.setTupleOnRow(qulifiedTuple);
    drill.setTuple(qulifiedTuple);
  }
}