Program: 5956
Project: 5956
Buggy source:
/** 
 * Creates a dataset instance.
 * @param namespaceId the namespace to create the dataset instance in
 * @param name the name of the new dataset instance
 * @param props the properties for the new dataset instance
 * @throws NamespaceNotFoundException if the specified namespace was not found
 * @throws DatasetAlreadyExistsException if a dataset with the same name already exists
 * @throws DatasetTypeNotFoundException if the dataset type was not found
 * @throws UnauthorizedException if perimeter security and authorization are enabled, and the current user does nothave  {@link Action#WRITE} privilege on the #instance's namespace
 */
void create(String namespaceId,String name,DatasetInstanceConfiguration props) throws Exception {
  Id.Namespace namespace=ConversionHelpers.toNamespaceId(namespaceId);
  Principal principal=authenticationContext.getPrincipal();
  authorizationEnforcer.enforce(namespace.toEntityId(),principal,Action.WRITE);
  ensureNamespaceExists(namespace);
  Id.DatasetInstance newInstance=ConversionHelpers.toDatasetInstanceId(namespaceId,name);
  DatasetSpecification existing=instanceManager.get(newInstance);
  if (existing != null) {
    throw new DatasetAlreadyExistsException(newInstance);
  }
  DatasetTypeMeta typeMeta=getTypeInfo(namespace,props.getTypeName());
  if (typeMeta == null) {
    throw new DatasetTypeNotFoundException(ConversionHelpers.toDatasetTypeId(namespace,props.getTypeName()));
  }
  DatasetId datasetId=newInstance.toEntityId();
  privilegesManager.revoke(datasetId);
  privilegesManager.grant(datasetId,principal,ImmutableSet.of(Action.ALL));
  LOG.info("String_Node_Str",namespaceId,name,props.getTypeName(),props.getProperties());
  try {
    DatasetSpecification spec=opExecutorClient.create(newInstance,typeMeta,DatasetProperties.builder().addAll(props.getProperties()).setDescription(props.getDescription()).build());
    instanceManager.add(namespace,spec);
    metaCache.invalidate(newInstance);
    publishAudit(newInstance,AuditType.CREATE);
    enableExplore(newInstance,spec,props);
  }
 catch (  Exception e) {
    privilegesManager.revoke(datasetId);
    throw e;
  }
}

Fixed version (ground truth):
/** 
 * Creates a dataset instance.
 * @param namespaceId the namespace to create the dataset instance in
 * @param name the name of the new dataset instance
 * @param props the properties for the new dataset instance
 * @throws NamespaceNotFoundException if the specified namespace was not found
 * @throws DatasetAlreadyExistsException if a dataset with the same name already exists
 * @throws DatasetTypeNotFoundException if the dataset type was not found
 * @throws UnauthorizedException if perimeter security and authorization are enabled, and the current user does nothave  {@link Action#WRITE} privilege on the #instance's namespace
 */
void create(String namespaceId,String name,DatasetInstanceConfiguration props) throws Exception {
  Id.Namespace namespace=ConversionHelpers.toNamespaceId(namespaceId);
  Principal principal=authenticationContext.getPrincipal();
  authorizationEnforcer.enforce(namespace.toEntityId(),principal,Action.WRITE);
  ensureNamespaceExists(namespace);
  Id.DatasetInstance newInstance=ConversionHelpers.toDatasetInstanceId(namespaceId,name);
  DatasetSpecification existing=instanceManager.get(newInstance);
  if (existing != null) {
    throw new DatasetAlreadyExistsException(newInstance);
  }
  DatasetTypeMeta typeMeta=getTypeInfo(namespace,props.getTypeName());
  if (typeMeta == null) {
    throw new DatasetTypeNotFoundException(ConversionHelpers.toDatasetTypeId(namespace,props.getTypeName()));
  }
  DatasetId datasetId=newInstance.toEntityId();
  privilegesManager.revoke(datasetId);
  privilegesManager.grant(datasetId,principal,EnumSet.allOf(Action.class));
  LOG.info("String_Node_Str",namespaceId,name,props.getTypeName(),props.getProperties());
  try {
    DatasetSpecification spec=opExecutorClient.create(newInstance,typeMeta,DatasetProperties.builder().addAll(props.getProperties()).setDescription(props.getDescription()).build());
    instanceManager.add(namespace,spec);
    metaCache.invalidate(newInstance);
    publishAudit(newInstance,AuditType.CREATE);
    enableExplore(newInstance,spec,props);
  }
 catch (  Exception e) {
    privilegesManager.revoke(datasetId);
    throw e;
  }
}