bbende commented on a change in pull request #4629: URL: https://github.com/apache/nifi/pull/4629#discussion_r516688495
########## File path: nifi-nar-bundles/nifi-extension-utils/nifi-hadoop-utils/src/main/java/org/apache/nifi/hadoop/CallableThrowingException.java ########## @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.hadoop; + +@FunctionalInterface +public interface CallableThrowingException<T, E extends Exception> { Review comment: This can be removed now that it is not used right? ########## File path: nifi-nar-bundles/nifi-extension-utils/nifi-hadoop-utils/src/main/java/org/apache/nifi/hadoop/SecurityUtil.java ########## @@ -141,4 +143,37 @@ public static boolean isSecurityEnabled(final Configuration config) { Validate.notNull(config); return KERBEROS.equalsIgnoreCase(config.get(HADOOP_SECURITY_AUTHENTICATION)); } + + public static <T> T callWithUgi(UserGroupInformation ugi, PrivilegedExceptionAction<T> action) throws IOException { + try { + return ugi.doAs(action); + } catch (InterruptedException e) { + throw new IOException(e); + } + } + + public static void checkTGTAndRelogin(ComponentLog log, KerberosUser kerberosUser, UserGroupInformation ugi) throws IOException { Review comment: It looks like only the method below that takes log and kerberosUser is used, can we remove this one if it is unused? ########## File path: nifi-nar-bundles/nifi-extension-utils/nifi-hadoop-utils/src/main/java/org/apache/nifi/hadoop/SecurityUtil.java ########## @@ -141,4 +143,37 @@ public static boolean isSecurityEnabled(final Configuration config) { Validate.notNull(config); return KERBEROS.equalsIgnoreCase(config.get(HADOOP_SECURITY_AUTHENTICATION)); } + + public static <T> T callWithUgi(UserGroupInformation ugi, PrivilegedExceptionAction<T> action) throws IOException { Review comment: It doesn't seem like we really need a utility method here just to call one line `return ugi.doAs(action);` , I think it would be simpler to just call `ugi.doAs` from all the places where this method is being called ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
