Program: 102569
Project: 102569
Buggy source:
/** 
 * Creates new group in /Spaces node and return groupId
 * @param spaceName String
 * @param creator   String
 * @return groupId String
 * @throws SpaceException
 */
public static String createGroup(String spaceName,String creator) throws SpaceException {
  OrganizationService organizationService=getOrganizationService();
  GroupHandler groupHandler=organizationService.getGroupHandler();
  Group parentGroup;
  Group newGroup;
  String groupId;
  String shortName;
  try {
    parentGroup=groupHandler.findGroupById(SPACE_GROUP);
    newGroup=groupHandler.createGroupInstance();
    shortName=SpaceUtils.cleanString(spaceName);
    groupId=parentGroup.getId() + "String_Node_Str" + shortName;
    PortalContainer portalContainer=PortalContainer.getInstance();
    SpaceService spaceService=(SpaceService)portalContainer.getComponentInstanceOfType(SpaceService.class);
    if (spaceService.getSpaceByGroupId(groupId) != null) {
      shortName=buildGroupId(shortName);
      groupId=parentGroup.getId() + "String_Node_Str" + shortName;
    }
    if (isSpaceNameExisted(spaceName)) {
      throw new SpaceException(SpaceException.Code.SPACE_ALREADY_EXIST);
    }
    newGroup.setGroupName(shortName);
    newGroup.setLabel(spaceName);
    newGroup.setDescription("String_Node_Str" + parentGroup.getId() + "String_Node_Str"+ shortName+ "String_Node_Str");
    groupHandler.addChild(parentGroup,newGroup,true);
  }
 catch (  Exception e) {
    if (e instanceof SpaceException) {
      throw (SpaceException)e;
    }
    throw new SpaceException(SpaceException.Code.UNABLE_TO_CREATE_GROUP,e);
  }
  try {
    addCreatorToGroup(creator,groupId);
  }
 catch (  Exception e) {
    throw new SpaceException(SpaceException.Code.UNABLE_TO_ADD_CREATOR,e);
  }
  return groupId;
}

Fixed version (ground truth):
/** 
 * Creates new group in /Spaces node and return groupId
 * @param spaceName String
 * @param creator   String
 * @return groupId String
 * @throws SpaceException
 */
public static String createGroup(String spaceName,String creator) throws SpaceException {
  OrganizationService organizationService=getOrganizationService();
  GroupHandler groupHandler=organizationService.getGroupHandler();
  Group parentGroup;
  Group newGroup;
  String groupId;
  String shortName;
  try {
    parentGroup=groupHandler.findGroupById(SPACE_GROUP);
    newGroup=groupHandler.createGroupInstance();
    shortName=SpaceUtils.cleanString(spaceName);
    groupId=parentGroup.getId() + "String_Node_Str" + shortName;
    PortalContainer portalContainer=PortalContainer.getInstance();
    SpaceService spaceService=(SpaceService)portalContainer.getComponentInstanceOfType(SpaceService.class);
    if (spaceService.getSpaceByGroupId(groupId) != null) {
      shortName=buildGroupId(shortName,parentGroup.getId());
      groupId=parentGroup.getId() + "String_Node_Str" + shortName;
    }
    if (isSpaceNameExisted(spaceName)) {
      throw new SpaceException(SpaceException.Code.SPACE_ALREADY_EXIST);
    }
    newGroup.setGroupName(shortName);
    newGroup.setLabel(spaceName);
    newGroup.setDescription("String_Node_Str" + parentGroup.getId() + "String_Node_Str"+ shortName+ "String_Node_Str");
    groupHandler.addChild(parentGroup,newGroup,true);
  }
 catch (  Exception e) {
    if (e instanceof SpaceException) {
      throw (SpaceException)e;
    }
    throw new SpaceException(SpaceException.Code.UNABLE_TO_CREATE_GROUP,e);
  }
  try {
    addCreatorToGroup(creator,groupId);
  }
 catch (  Exception e) {
    throw new SpaceException(SpaceException.Code.UNABLE_TO_ADD_CREATOR,e);
  }
  return groupId;
}