Program: 5017
Project: 5017
Buggy source:
private void createLocation(NamespaceMeta namespaceMeta) throws IOException {
  NamespaceId namespaceId=namespaceMeta.getNamespaceId();
  boolean createdHome=false;
  Location namespaceHome;
  if (hasCustomLocation(namespaceMeta)) {
    namespaceHome=validateCustomLocation(namespaceMeta);
  }
 else {
    namespaceHome=namespacedLocationFactory.get(namespaceMeta);
    if (namespaceHome.exists()) {
      throw new FileAlreadyExistsException(namespaceHome.toString());
    }
    createdHome=createNamespaceDir(namespaceHome,"String_Node_Str",namespaceId);
  }
  Location dataLoc=namespaceHome.append(Constants.Dataset.DEFAULT_DATA_DIR);
  Location tempLoc=namespaceHome.append(cConf.get(Constants.AppFabric.TEMP_DIR));
  Location streamsLoc=namespaceHome.append(cConf.get(Constants.Stream.BASE_DIR));
  Location deletedLoc=streamsLoc.append(StreamUtils.DELETED);
  String configuredGroupName=namespaceMeta.getConfig().getGroupName();
  boolean createdData=false;
  boolean createdTemp=false;
  boolean createdStreams=false;
  try {
    if (createdHome && SecurityUtil.isKerberosEnabled(cConf)) {
      String groupToSet=configuredGroupName;
      if (groupToSet == null) {
        String[] groups=UserGroupInformation.getCurrentUser().getGroupNames();
        if (groups != null && groups.length > 0) {
          groupToSet=groups[0];
        }
      }
      if (groupToSet != null) {
        namespaceHome.setGroup(groupToSet);
      }
    }
    createdData=createNamespaceDir(dataLoc,"String_Node_Str",namespaceId);
    createdTemp=createNamespaceDir(tempLoc,"String_Node_Str",namespaceId);
    createdStreams=createNamespaceDir(streamsLoc,"String_Node_Str",namespaceId);
    createNamespaceDir(deletedLoc,"String_Node_Str",namespaceId);
    if (SecurityUtil.isKerberosEnabled(cConf)) {
      String groupToSet=configuredGroupName != null ? configuredGroupName : namespaceHome.getGroup();
      for (      Location loc : new Location[]{dataLoc,tempLoc,streamsLoc,deletedLoc}) {
        loc.setGroup(groupToSet);
        if (configuredGroupName != null) {
          String permissions=loc.getPermissions();
          loc.setPermissions(permissions.substring(0,3) + "String_Node_Str" + permissions.substring(6));
        }
      }
    }
  }
 catch (  Throwable t) {
    if (createdHome) {
      deleteDirSilently(namespaceHome,t,"String_Node_Str",namespaceMeta.getNamespaceId());
    }
 else {
      if (createdData) {
        deleteDirSilently(dataLoc,t,"String_Node_Str",namespaceMeta.getNamespaceId());
      }
      if (createdTemp) {
        deleteDirSilently(tempLoc,t,"String_Node_Str",namespaceMeta.getNamespaceId());
      }
      if (createdStreams) {
        deleteDirSilently(streamsLoc,t,"String_Node_Str",namespaceMeta.getNamespaceId());
      }
    }
    throw t;
  }
}

Fixed version (ground truth):
private void createLocation(NamespaceMeta namespaceMeta) throws IOException {
  NamespaceId namespaceId=namespaceMeta.getNamespaceId();
  boolean createdHome=false;
  Location namespaceHome;
  if (hasCustomLocation(namespaceMeta)) {
    namespaceHome=validateCustomLocation(namespaceMeta);
  }
 else {
    namespaceHome=namespacedLocationFactory.get(namespaceMeta);
    if (namespaceHome.exists()) {
      throw new FileAlreadyExistsException(null,null,String.format("String_Node_Str",namespaceHome,namespaceId));
    }
    createdHome=createNamespaceDir(namespaceHome,"String_Node_Str",namespaceId);
  }
  Location dataLoc=namespaceHome.append(Constants.Dataset.DEFAULT_DATA_DIR);
  Location tempLoc=namespaceHome.append(cConf.get(Constants.AppFabric.TEMP_DIR));
  Location streamsLoc=namespaceHome.append(cConf.get(Constants.Stream.BASE_DIR));
  Location deletedLoc=streamsLoc.append(StreamUtils.DELETED);
  String configuredGroupName=namespaceMeta.getConfig().getGroupName();
  boolean createdData=false;
  boolean createdTemp=false;
  boolean createdStreams=false;
  try {
    if (createdHome && SecurityUtil.isKerberosEnabled(cConf)) {
      String groupToSet=configuredGroupName;
      if (groupToSet == null) {
        String[] groups=UserGroupInformation.getCurrentUser().getGroupNames();
        if (groups != null && groups.length > 0) {
          groupToSet=groups[0];
        }
      }
      if (groupToSet != null) {
        namespaceHome.setGroup(groupToSet);
      }
    }
    createdData=createNamespaceDir(dataLoc,"String_Node_Str",namespaceId);
    createdTemp=createNamespaceDir(tempLoc,"String_Node_Str",namespaceId);
    createdStreams=createNamespaceDir(streamsLoc,"String_Node_Str",namespaceId);
    createNamespaceDir(deletedLoc,"String_Node_Str",namespaceId);
    if (SecurityUtil.isKerberosEnabled(cConf)) {
      String groupToSet=configuredGroupName != null ? configuredGroupName : namespaceHome.getGroup();
      for (      Location loc : new Location[]{dataLoc,tempLoc,streamsLoc,deletedLoc}) {
        loc.setGroup(groupToSet);
        if (configuredGroupName != null) {
          String permissions=loc.getPermissions();
          loc.setPermissions(permissions.substring(0,3) + "String_Node_Str" + permissions.substring(6));
        }
      }
    }
  }
 catch (  Throwable t) {
    if (createdHome) {
      deleteDirSilently(namespaceHome,t,"String_Node_Str",namespaceMeta.getNamespaceId());
    }
 else {
      if (createdData) {
        deleteDirSilently(dataLoc,t,"String_Node_Str",namespaceMeta.getNamespaceId());
      }
      if (createdTemp) {
        deleteDirSilently(tempLoc,t,"String_Node_Str",namespaceMeta.getNamespaceId());
      }
      if (createdStreams) {
        deleteDirSilently(streamsLoc,t,"String_Node_Str",namespaceMeta.getNamespaceId());
      }
    }
    throw t;
  }
}