Program: 5195
Project: 5195
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);
  }
  boolean hasValidKerberosConf=false;
  if (metadata.getConfig() != null) {
    String configuredPrincipal=metadata.getConfig().getPrincipal();
    String configuredKeytabURI=metadata.getConfig().getKeytabURI();
    if ((!Strings.isNullOrEmpty(configuredPrincipal) && Strings.isNullOrEmpty(configuredKeytabURI)) || (Strings.isNullOrEmpty(configuredPrincipal) && !Strings.isNullOrEmpty(configuredKeytabURI))) {
      throw new BadRequestException(String.format("String_Node_Str" + "String_Node_Str",configuredPrincipal,configuredKeytabURI));
    }
    hasValidKerberosConf=true;
  }
  if (!metadata.getConfig().isExploreAsPrincipal() && !hasValidKerberosConf) {
    throw new BadRequestException(String.format("String_Node_Str",NamespaceConfig.EXPLORE_AS_PRINCIPAL));
  }
  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);
  try {
    UserGroupInformation ugi;
    if (NamespaceId.DEFAULT.equals(namespace)) {
      ugi=UserGroupInformation.getCurrentUser();
    }
 else {
      ugi=impersonator.getUGI(namespace);
    }
    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(),metadata);
}

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);
  }
  boolean hasValidKerberosConf=false;
  if (metadata.getConfig() != null) {
    String configuredPrincipal=metadata.getConfig().getPrincipal();
    String configuredKeytabURI=metadata.getConfig().getKeytabURI();
    if ((!Strings.isNullOrEmpty(configuredPrincipal) && Strings.isNullOrEmpty(configuredKeytabURI)) || (Strings.isNullOrEmpty(configuredPrincipal) && !Strings.isNullOrEmpty(configuredKeytabURI))) {
      throw new BadRequestException(String.format("String_Node_Str" + "String_Node_Str",configuredPrincipal,configuredKeytabURI));
    }
    hasValidKerberosConf=true;
  }
  if (!metadata.getConfig().isExploreAsPrincipal() && !hasValidKerberosConf) {
    throw new BadRequestException(String.format("String_Node_Str",NamespaceConfig.EXPLORE_AS_PRINCIPAL));
  }
  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=new KerberosName(SecurityUtil.getMasterPrincipal(cConf)).getShortName();
    }
 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);
  try {
    UserGroupInformation ugi;
    if (NamespaceId.DEFAULT.equals(namespace)) {
      ugi=UserGroupInformation.getCurrentUser();
    }
 else {
      ugi=impersonator.getUGI(namespace);
    }
    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(),metadata);
}