Program: 63259
Project: 63259
Buggy source:
private void initDimensionColumns(Map<String,TableDesc> tables){
  for (  DimensionDesc dim : dimensions) {
    TableDesc dimTable=dim.getTableDesc();
    JoinDesc join=dim.getJoin();
    ArrayList<TblColRef> dimColList=new ArrayList<TblColRef>();
    ArrayList<TblColRef> hostColList=new ArrayList<TblColRef>();
    if (dim.getColumn() != null) {
      if (join != null) {
        for (        TblColRef ref : join.getForeignKeyColumns()) {
          TblColRef inited=initDimensionColRef(ref);
          dimColList.add(inited);
          hostColList.add(inited);
        }
      }
 else {
        for (        String aColumn : dim.getColumn()) {
          TblColRef ref=initDimensionColRef(dimTable,aColumn);
          dimColList.add(ref);
          hostColList.add(ref);
        }
      }
    }
    if (dim.getHierarchy() != null) {
      for (      HierarchyDesc hier : dim.getHierarchy()) {
        TblColRef ref=initDimensionColRef(dimTable,hier.getColumn());
        hier.setColumnRef(ref);
        dimColList.add(ref);
      }
      if (hostColList.isEmpty()) {
        hostColList.add(dimColList.get(dimColList.size() - 1));
      }
    }
    TblColRef[] dimCols=(TblColRef[])dimColList.toArray(new TblColRef[dimColList.size()]);
    dim.setColumnRefs(dimCols);
    TblColRef[] hostCols=(TblColRef[])hostColList.toArray(new TblColRef[hostColList.size()]);
    String[] derived=dim.getDerived();
    if (derived != null) {
      String[][] split=splitDerivedColumnAndExtra(derived);
      String[] derivedNames=split[0];
      String[] derivedExtra=split[1];
      TblColRef[] derivedCols=new TblColRef[derivedNames.length];
      for (int i=0; i < derivedNames.length; i++) {
        derivedCols[i]=initDimensionColRef(dimTable,derivedNames[i]);
      }
      initDerivedMap(hostCols,DeriveType.LOOKUP,dim,derivedCols,derivedExtra);
    }
    if (join != null) {
      TblColRef[] fk=join.getForeignKeyColumns();
      TblColRef[] pk=join.getPrimaryKeyColumns();
      for (int i=0; i < fk.length; i++) {
        int find=ArrayUtils.indexOf(hostCols,fk[i]);
        if (find >= 0) {
          TblColRef derivedCol=initDimensionColRef(pk[i]);
          initDerivedMap(hostCols[find],DeriveType.PK_FK,dim,derivedCol);
        }
      }
      for (int i=0; i < pk.length; i++) {
        int find=ArrayUtils.indexOf(hostCols,pk[i]);
        if (find >= 0) {
          TblColRef derivedCol=initDimensionColRef(fk[i]);
          initDerivedMap(hostCols[find],DeriveType.PK_FK,dim,derivedCol);
        }
      }
    }
  }
}

Fixed version (ground truth):
private void initDimensionColumns(Map<String,TableDesc> tables){
  for (  DimensionDesc dim : dimensions) {
    TableDesc dimTable=dim.getTableDesc();
    JoinDesc join=dim.getJoin();
    ArrayList<TblColRef> dimColList=new ArrayList<TblColRef>();
    ArrayList<TblColRef> hostColList=new ArrayList<TblColRef>();
    if (dim.getColumn() != null) {
      if (join != null) {
        for (        TblColRef ref : join.getForeignKeyColumns()) {
          TblColRef inited=initDimensionColRef(ref);
          dimColList.add(inited);
          hostColList.add(inited);
        }
      }
 else {
        for (        String aColumn : dim.getColumn()) {
          TblColRef ref=initDimensionColRef(dimTable,aColumn);
          if (!dimColList.contains(ref)) {
            dimColList.add(ref);
          }
        }
      }
    }
    if (dim.getHierarchy() != null) {
      for (      HierarchyDesc hier : dim.getHierarchy()) {
        TblColRef ref=initDimensionColRef(dimTable,hier.getColumn());
        hier.setColumnRef(ref);
        if (!dimColList.contains(ref))         dimColList.add(ref);
      }
      if (hostColList.isEmpty()) {
        hostColList.add(dimColList.get(dimColList.size() - 1));
      }
    }
    TblColRef[] dimCols=(TblColRef[])dimColList.toArray(new TblColRef[dimColList.size()]);
    dim.setColumnRefs(dimCols);
    TblColRef[] hostCols=(TblColRef[])hostColList.toArray(new TblColRef[hostColList.size()]);
    String[] derived=dim.getDerived();
    if (derived != null) {
      String[][] split=splitDerivedColumnAndExtra(derived);
      String[] derivedNames=split[0];
      String[] derivedExtra=split[1];
      TblColRef[] derivedCols=new TblColRef[derivedNames.length];
      for (int i=0; i < derivedNames.length; i++) {
        derivedCols[i]=initDimensionColRef(dimTable,derivedNames[i]);
      }
      initDerivedMap(hostCols,DeriveType.LOOKUP,dim,derivedCols,derivedExtra);
    }
    if (join != null) {
      TblColRef[] fk=join.getForeignKeyColumns();
      TblColRef[] pk=join.getPrimaryKeyColumns();
      for (int i=0; i < fk.length; i++) {
        int find=ArrayUtils.indexOf(hostCols,fk[i]);
        if (find >= 0) {
          TblColRef derivedCol=initDimensionColRef(pk[i]);
          initDerivedMap(hostCols[find],DeriveType.PK_FK,dim,derivedCol);
        }
      }
      for (int i=0; i < pk.length; i++) {
        int find=ArrayUtils.indexOf(hostCols,pk[i]);
        if (find >= 0) {
          TblColRef derivedCol=initDimensionColRef(fk[i]);
          initDerivedMap(hostCols[find],DeriveType.PK_FK,dim,derivedCol);
        }
      }
    }
  }
}