Program: 5419
Project: 5419
Buggy source:
/** 
 * Creates a new namespace
 * @param metadata the {@link NamespaceMeta} for the new namespace to be created
 * @throws NamespaceAlreadyExistsException if the specified namespace already exists
 */
@Override @AuthEnforce(entities="String_Node_Str",enforceOn=InstanceId.class,actions=Action.ADMIN) public synchronized void create(final NamespaceMeta metadata) throws Exception {
  Preconditions.checkArgument(metadata != null,"String_Node_Str");
  NamespaceId namespace=metadata.getNamespaceId();
  if (exists(namespace)) {
    throw new NamespaceAlreadyExistsException(namespace);
  }
  if (hasCustomMapping(metadata)) {
    validateCustomMapping(metadata);
  }
  Principal principal=authenticationContext.getPrincipal();
  privilegesManager.grant(namespace,principal,EnumSet.allOf(Action.class));
  String executionUserName;
  if (SecurityUtil.isKerberosEnabled(cConf) && !NamespaceId.SYSTEM.equals(namespace)) {
    String namespacePrincipal=metadata.getConfig().getPrincipal();
    if (Strings.isNullOrEmpty(namespacePrincipal)) {
      executionUserName=ImpersonationInfo.getMasterImpersonationInfo(cConf).getPrincipal();
    }
 else {
      executionUserName=new KerberosName(namespacePrincipal).getShortName();
    }
  }
 else {
    executionUserName=UserGroupInformation.getCurrentUser().getShortUserName();
  }
  Principal executionUser=new Principal(executionUserName,Principal.PrincipalType.USER);
  privilegesManager.grant(namespace,executionUser,EnumSet.allOf(Action.class));
  nsStore.create(metadata);
  UserGroupInformation ugi;
  if (NamespaceId.DEFAULT.equals(namespace)) {
    ugi=UserGroupInformation.getCurrentUser();
  }
 else {
    ugi=impersonator.getUGI(namespace);
  }
  try {
    ImpersonationUtils.doAs(ugi,new Callable<Void>(){
      @Override public Void call() throws Exception {
        storageProviderNamespaceAdmin.get().create(metadata);
        return null;
      }
    }
);
  }
 catch (  Throwable t) {
    deleteNamespaceMeta(metadata.getNamespaceId());
    privilegesManager.revoke(namespace);
    throw new NamespaceCannotBeCreatedException(namespace,t);
  }
  LOG.info("String_Node_Str",metadata.getNamespaceId());
}

Fixed version (ground truth):
/** 
 * Creates a new namespace
 * @param metadata the {@link NamespaceMeta} for the new namespace to be created
 * @throws NamespaceAlreadyExistsException if the specified namespace already exists
 */
@Override @AuthEnforce(entities="String_Node_Str",enforceOn=InstanceId.class,actions=Action.ADMIN) public synchronized void create(final NamespaceMeta metadata) throws Exception {
  Preconditions.checkArgument(metadata != null,"String_Node_Str");
  NamespaceId namespace=metadata.getNamespaceId();
  if (exists(namespace)) {
    throw new NamespaceAlreadyExistsException(namespace);
  }
  if (hasCustomMapping(metadata)) {
    validateCustomMapping(metadata);
  }
  Principal principal=authenticationContext.getPrincipal();
  privilegesManager.grant(namespace,principal,EnumSet.allOf(Action.class));
  String executionUserName;
  if (SecurityUtil.isKerberosEnabled(cConf) && !NamespaceId.SYSTEM.equals(namespace)) {
    String namespacePrincipal=metadata.getConfig().getPrincipal();
    if (Strings.isNullOrEmpty(namespacePrincipal)) {
      executionUserName=SecurityUtil.getMasterPrincipal(cConf);
    }
 else {
      executionUserName=new KerberosName(namespacePrincipal).getShortName();
    }
  }
 else {
    executionUserName=UserGroupInformation.getCurrentUser().getShortUserName();
  }
  Principal executionUser=new Principal(executionUserName,Principal.PrincipalType.USER);
  privilegesManager.grant(namespace,executionUser,EnumSet.allOf(Action.class));
  nsStore.create(metadata);
  UserGroupInformation ugi;
  if (NamespaceId.DEFAULT.equals(namespace)) {
    ugi=UserGroupInformation.getCurrentUser();
  }
 else {
    ugi=impersonator.getUGI(namespace);
  }
  try {
    ImpersonationUtils.doAs(ugi,new Callable<Void>(){
      @Override public Void call() throws Exception {
        storageProviderNamespaceAdmin.get().create(metadata);
        return null;
      }
    }
);
  }
 catch (  Throwable t) {
    deleteNamespaceMeta(metadata.getNamespaceId());
    privilegesManager.revoke(namespace);
    throw new NamespaceCannotBeCreatedException(namespace,t);
  }
  LOG.info("String_Node_Str",metadata.getNamespaceId());
}