code: public static <T> T runPrivileged(UserGroupInformation login,
                                      PrivilegedExceptionAction<T> action) {
      try {
        if (login == null) {
          return action.run();
        } else {
          return login.doAs(action);
        }
      } catch (IOException ex) {
        throw new DatasetIOException("Privileged action failed", ex);
      } catch (InterruptedException ex) {
        Thread.interrupted();
        throw new DatasetException(ex);
      } catch (Exception ex) {
        throw Throwables.propagate(ex);
      }
    }
docs: Allow methods to act with the privileges of a login.
  
  If the login is null, the current privileges will be used.
  
  @param <T> The return type of the action
  @param login UserGroupInformation credentials to use for action
  @param action A PrivilegedExceptionAction to perform as another user
  @return the T value returned by action.run()