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


##########
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:
   What I don't want is to catch a throwable coming from `consumer.accept` 
because what this method should do is to skip when executors that don't load. 
If an error is thrown in `accept`, it is the callers decision to either skip 
the row (by catching the exception before leaving `consume`) or abort the whole 
loop (by throwing to `forEachExecutorThatLoads`



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