vrajat commented on code in PR #14747:
URL: https://github.com/apache/pinot/pull/14747#discussion_r1901601270


##########
pinot-spi/src/main/java/org/apache/pinot/spi/executor/ExecutorServiceUtils.java:
##########
@@ -51,14 +54,38 @@ public class ExecutorServiceUtils {
 
   static {
     PROVIDERS = new HashMap<>();
-    for (ExecutorServicePlugin plugin : 
ServiceLoader.load(ExecutorServicePlugin.class)) {
+    forEachExecutorThatLoads(plugin -> {
       ExecutorServiceProvider provider = plugin.provider();
       ExecutorServiceProvider old = PROVIDERS.put(plugin.id(), provider);
       if (old != null) {
         LOGGER.warn("Duplicate executor provider for id '{}': {} and {}", 
plugin.id(), old, provider);
       } else {
         LOGGER.info("Registered executor provider for id '{}': {}", 
plugin.id(), provider);
       }
+    });
+  }
+
+  private static void forEachExecutorThatLoads(Consumer<ExecutorServicePlugin> 
consumer) {
+    Iterator<ExecutorServicePlugin> iterator = 
ServiceLoader.load(ExecutorServicePlugin.class).iterator();
+    while (hasNextOrSkip(iterator)) {
+      ExecutorServicePlugin next;
+      try {
+        next = iterator.next();
+      } catch (ServiceConfigurationError e) {
+        LOGGER.warn("Skipping executor service plugin that doesn't load", e);
+        continue;
+      }
+      consumer.accept(next);

Review Comment:
   nit: Can this be moved to the try block and continue removed ? Curious if 
this code pattern is a requirement.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to