mirror of https://github.com/apache/nifi.git
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:
parent
9266212117
commit
f2a03fca2a
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue