Program: 5841
Project: 5841
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 public synchronized void create(final NamespaceMeta metadata) throws Exception {
  Preconditions.checkArgument(metadata != null,"String_Node_Str");
  NamespaceId namespace=new NamespaceId(metadata.getName());
  if (exists(namespace.toId())) {
    throw new NamespaceAlreadyExistsException(namespace.toId());
  }
  if (hasCustomMapping(metadata)) {
    validateCustomMapping(metadata);
  }
  Principal principal=authenticationContext.getPrincipal();
  authorizationEnforcer.enforce(instanceId,principal,Action.ADMIN);
  privilegesManager.grant(namespace,principal,EnumSet.allOf(Action.class));
  String executionUserName;
  if (SecurityUtil.isKerberosEnabled(cConf)) {
    ImpersonationInfo impersonationInfo=new ImpersonationInfo(metadata,cConf);
    String namespacePrincipal=impersonationInfo.getPrincipal();
    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 {
    impersonator.doAs(metadata,new Callable<Void>(){
      @Override public Void call() throws Exception {
        storageProviderNamespaceAdmin.get().create(metadata);
        return null;
      }
    }
);
  }
 catch (  IOException|ExploreException|SQLException e) {
    deleteNamespaceMeta(metadata.getNamespaceId());
    privilegesManager.revoke(namespace);
    throw new NamespaceCannotBeCreatedException(namespace.toId(),e);
  }
}

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 public synchronized void create(final NamespaceMeta metadata) throws Exception {
  Preconditions.checkArgument(metadata != null,"String_Node_Str");
  NamespaceId namespace=new NamespaceId(metadata.getName());
  if (exists(namespace.toId())) {
    throw new NamespaceAlreadyExistsException(namespace.toId());
  }
  if (hasCustomMapping(metadata)) {
    validateCustomMapping(metadata);
  }
  Principal principal=authenticationContext.getPrincipal();
  authorizationEnforcer.enforce(instanceId,principal,Action.ADMIN);
  privilegesManager.grant(namespace,principal,EnumSet.allOf(Action.class));
  String executionUserName;
  if (SecurityUtil.isKerberosEnabled(cConf)) {
    ImpersonationInfo impersonationInfo=new ImpersonationInfo(metadata,cConf);
    String namespacePrincipal=impersonationInfo.getPrincipal();
    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 {
    impersonator.doAs(metadata,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.toId(),t);
  }
}