This is an automated email from the ASF dual-hosted git repository.

chesnay pushed a commit to branch release-1.14
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 43015c06b59136bf68dbb85e26dee960bfe24809
Author: Chesnay Schepler <[email protected]>
AuthorDate: Fri Sep 24 09:29:28 2021 +0200

    [FLINK-24367] RpcSystem#loader evaluates all service entries
---
 .../java/org/apache/flink/runtime/rpc/RpcSystem.java     | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git 
a/flink-rpc/flink-rpc-core/src/main/java/org/apache/flink/runtime/rpc/RpcSystem.java
 
b/flink-rpc/flink-rpc-core/src/main/java/org/apache/flink/runtime/rpc/RpcSystem.java
index 9f76e8d..e6eab2d 100644
--- 
a/flink-rpc/flink-rpc-core/src/main/java/org/apache/flink/runtime/rpc/RpcSystem.java
+++ 
b/flink-rpc/flink-rpc-core/src/main/java/org/apache/flink/runtime/rpc/RpcSystem.java
@@ -18,9 +18,11 @@
 package org.apache.flink.runtime.rpc;
 
 import org.apache.flink.configuration.Configuration;
+import org.apache.flink.util.ExceptionUtils;
 
 import javax.annotation.Nullable;
 
+import java.util.Iterator;
 import java.util.ServiceLoader;
 
 /**
@@ -88,7 +90,19 @@ public interface RpcSystem extends RpcSystemUtils, 
AutoCloseable {
      * @return loaded RpcSystem
      */
     static RpcSystem load(Configuration config) {
-        return 
ServiceLoader.load(RpcSystemLoader.class).iterator().next().loadRpcSystem(config);
+        final Iterator<RpcSystemLoader> iterator =
+                ServiceLoader.load(RpcSystemLoader.class).iterator();
+
+        Exception loadError = null;
+        while (iterator.hasNext()) {
+            final RpcSystemLoader next = iterator.next();
+            try {
+                return next.loadRpcSystem(config);
+            } catch (Exception e) {
+                loadError = ExceptionUtils.firstOrSuppressed(e, loadError);
+            }
+        }
+        throw new RuntimeException("Could not load RpcSystem.", loadError);
     }
 
     /** Descriptor for creating a fork-join thread-pool. */

Reply via email to