diff --git a/nifi-nar-bundles/nifi-extension-utils/nifi-hadoop-utils/src/main/java/org/apache/nifi/hadoop/SecurityUtil.java b/nifi-nar-bundles/nifi-extension-utils/nifi-hadoop-utils/src/main/java/org/apache/nifi/hadoop/SecurityUtil.java index 85c0829664..6bf0aa5b7a 100644 --- a/nifi-nar-bundles/nifi-extension-utils/nifi-hadoop-utils/src/main/java/org/apache/nifi/hadoop/SecurityUtil.java +++ b/nifi-nar-bundles/nifi-extension-utils/nifi-hadoop-utils/src/main/java/org/apache/nifi/hadoop/SecurityUtil.java @@ -151,7 +151,21 @@ public class SecurityUtil { public static T callWithUgi(UserGroupInformation ugi, PrivilegedExceptionAction action) throws IOException { try { - return ugi.doAs(action); + T result; + if (ugi == null) { + try { + result = action.run(); + } catch (IOException ioe) { + throw ioe; + } catch (RuntimeException re) { + throw re; + } catch (Exception e) { + throw new RuntimeException(e); + } + } else { + result = ugi.doAs(action); + } + return result; } catch (InterruptedException e) { throw new IOException(e); }