leventov commented on a change in pull request #7789: Druid basic 
authentication class composition config
URL: https://github.com/apache/incubator-druid/pull/7789#discussion_r288702717
 
 

 ##########
 File path: 
extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/BasicSecurityDruidModule.java
 ##########
 @@ -168,6 +211,33 @@ public static BasicAuthorizerCacheNotifier 
createAuthorizerCacheNotifier(final I
     );
   }
 
+  /**
+   * Returns the instance provided either by a config property or 
coordinator-run class or default class.
+   * The order of check corresponds to the order of method params.
+   */
+  @Nullable
+  public static <T> T getInstance(
+      Injector injector,
+      String configClassName,
+      Class<? extends T> classRunByCoordinator,
+      Class<? extends T> defaultClass
+  ) throws ClassNotFoundException
+  {
+    if (configClassName != null) {
+      // ClassCastException is thrown in case of a mismatch, configuration fix 
is required.
+      @SuppressWarnings("unchecked")
+      final T instance = (T) 
injector.getInstance(Class.forName(configClassName));
+      return instance;
+    }
+    if (classRunByCoordinator != null && isCoordinator(injector)) {
+      return injector.getInstance(classRunByCoordinator);
+    }
+    if (defaultClass != null) {
+      return injector.getInstance(defaultClass);
+    }
+    return null;
 
 Review comment:
   Why not to throw an AssertException then (and log `assertionError()`)?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to