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.
This commit is contained in:
tpalfy 2021-03-08 15:10:12 +01:00 committed by GitHub
parent 9266212117
commit f2a03fca2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 1 deletions

View File

@ -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);
}