You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "turcsanyip (via GitHub)" <gi...@apache.org> on 2023/04/04 18:17:25 UTC

[GitHub] [nifi] turcsanyip commented on a diff in pull request #7121: NIFI-11342: HDFS processors fail to get ClassloaderIsolationKey at startup

turcsanyip commented on code in PR #7121:
URL: https://github.com/apache/nifi/pull/7121#discussion_r1157608507


##########
nifi-nar-bundles/nifi-extension-utils/nifi-hadoop-utils/src/main/java/org/apache/nifi/processors/hadoop/AbstractHadoopProcessor.java:
##########
@@ -211,18 +211,22 @@ public String getClassloaderIsolationKey(final PropertyContext context) {
             return explicitKerberosPrincipal;
         }
 
-        final KerberosCredentialsService credentialsService = context.getProperty(KERBEROS_CREDENTIALS_SERVICE).asControllerService(KerberosCredentialsService.class);
-        if (credentialsService != null) {
-            final String credentialsServicePrincipal = credentialsService.getPrincipal();
-            if (credentialsServicePrincipal != null) {
-                return credentialsServicePrincipal;
+        try {
+            final KerberosCredentialsService credentialsService = context.getProperty(KERBEROS_CREDENTIALS_SERVICE).asControllerService(KerberosCredentialsService.class);
+            if (credentialsService != null) {
+                final String credentialsServicePrincipal = credentialsService.getPrincipal();
+                if (credentialsServicePrincipal != null) {
+                    return credentialsServicePrincipal;
+                }
             }
-        }
 
-        final KerberosUserService kerberosUserService = context.getProperty(KERBEROS_USER_SERVICE).asControllerService(KerberosUserService.class);
-        if (kerberosUserService != null) {
-            final KerberosUser kerberosUser = kerberosUserService.createKerberosUser();
-            return kerberosUser.getPrincipal();
+            final KerberosUserService kerberosUserService = context.getProperty(KERBEROS_USER_SERVICE).asControllerService(KerberosUserService.class);
+            if (kerberosUserService != null) {
+                final KerberosUser kerberosUser = kerberosUserService.createKerberosUser();
+                return kerberosUser.getPrincipal();
+            }
+        } catch (Exception e) {

Review Comment:
   @mark-bathori Thanks for handling this "Controller Service's State is currently DISABLED" issue!
   Instead of the generic `Exception`, only `ControllerServiceDisabledException` should be caught and handled but it is not visible here (and we definitely do not want to add `nifi-framework-core-api`). This exception is a child of `IllegalStateException` which could be used in the catch block to narrow the scope.
   



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org