Program: 76576
Project: 76576
Buggy source:
/** 
 * @throws DataException
 */
private void prepare() throws DataException {
  Context cx=Context.enter();
  try {
    if (this.baseQueryDefn.getResultSetExpressions() != null && this.baseQueryDefn.getResultSetExpressions().size() > 0) {
      this.expressionCompiler.setDataSetMode(false);
    }
    List groups=baseQueryDefn.getGroups();
    Set groupNameSet=new HashSet();
    IGroupDefinition group;
    for (int i=0; i < groups.size(); i++) {
      group=(IGroupDefinition)groups.get(i);
      if (group.getName() == null || group.getName().trim().length() == 0)       continue;
      for (int j=0; j < groups.size(); j++) {
        if (group.getName().equals(((IGroupDefinition)groups.get(j)).getName() == null ? "String_Node_Str" : ((IGroupDefinition)groups.get(j)).getName()) && j != i)         throw new DataException(ResourceConstants.DUPLICATE_GROUP_NAME);
      }
      groupNameSet.add(group.getName());
    }
    Map map=baseQueryDefn.getResultSetExpressions();
    if (map != null) {
      Iterator it=map.keySet().iterator();
      while (it.hasNext()) {
        Object key=it.next();
        IBaseExpression icbe=(IBaseExpression)map.get(key);
        if ((!icbe.getGroupName().equals(IBaseExpression.GROUP_OVERALL)) && !groupNameSet.contains(icbe.getGroupName())) {
          throw new DataException(ResourceConstants.GROUP_NOT_EXIST,new Object[]{icbe.getGroupName(),key});
        }
        validateColumnBinding(key.toString(),map,icbe);
      }
    }
    mappingParentColumnBinding();
    for (int i=0; i <= groups.size(); i++) {
      prepareGroup(baseQueryDefn,i,cx);
    }
  }
  finally {
    Context.exit();
  }
}

Fixed version (ground truth):
/** 
 * @throws DataException
 */
private void prepare() throws DataException {
  Context cx=Context.enter();
  try {
    if (this.baseQueryDefn.getResultSetExpressions() != null && this.baseQueryDefn.getResultSetExpressions().size() > 0) {
      this.expressionCompiler.setDataSetMode(false);
    }
    List groups=baseQueryDefn.getGroups();
    Set groupNameSet=new HashSet();
    IGroupDefinition group;
    for (int i=0; i < groups.size(); i++) {
      group=(IGroupDefinition)groups.get(i);
      if (group.getName() == null || group.getName().trim().length() == 0)       continue;
      for (int j=0; j < groups.size(); j++) {
        if (group.getName().equals(((IGroupDefinition)groups.get(j)).getName() == null ? "String_Node_Str" : ((IGroupDefinition)groups.get(j)).getName()) && j != i)         throw new DataException(ResourceConstants.DUPLICATE_GROUP_NAME);
      }
      groupNameSet.add(group.getName());
    }
    Map map=baseQueryDefn.getResultSetExpressions();
    if (map != null) {
      Iterator it=map.keySet().iterator();
      while (it.hasNext()) {
        Object key=it.next();
        IBaseExpression icbe=(IBaseExpression)map.get(key);
        if ((!icbe.getGroupName().equals(IBaseExpression.GROUP_OVERALL)) && !groupNameSet.contains(icbe.getGroupName())) {
          throw new DataException(ResourceConstants.GROUP_NOT_EXIST,new Object[]{icbe.getGroupName(),key});
        }
      }
    }
    mappingParentColumnBinding();
    for (int i=0; i <= groups.size(); i++) {
      prepareGroup(baseQueryDefn,i,cx);
    }
  }
  finally {
    Context.exit();
  }
}