This is an automated email from the ASF dual-hosted git repository. joewitt pushed a commit to branch support/nifi-1.13 in repository https://gitbox.apache.org/repos/asf/nifi.git
commit 03243fd013b3cebdb13f95288d1534580a006a80 Author: tpalfy <[email protected]> AuthorDate: Mon Mar 8 15:10:12 2021 +0100 NIFI-8285 Prevent HBase client services to throw NPE in non-kerberized environment. (#4868) * NIFI-8285 Prevent HBase client services to throw NPE in non-kerberized environment. * NIFI-8285 Improve exception handling. --- .../main/java/org/apache/nifi/hadoop/SecurityUtil.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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 85c0829..6bf0aa5 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> T callWithUgi(UserGroupInformation ugi, PrivilegedExceptionAction<T> 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); }
