You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by sn...@apache.org on 2026/05/26 06:48:31 UTC

(flink) branch master updated: [FLINK-38503] Adapt `DefaultClusterClientServiceLoader` to java 25

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

snuyanzin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new 45295cf6260 [FLINK-38503] Adapt `DefaultClusterClientServiceLoader` to java 25
45295cf6260 is described below

commit 45295cf62608ca172b83ac42d9128d027a91d06a
Author: Sergey Nuyanzin <sn...@gmail.com>
AuthorDate: Tue May 26 08:48:24 2026 +0200

    [FLINK-38503] Adapt `DefaultClusterClientServiceLoader` to java 25
---
 .../DefaultClusterClientServiceLoader.java          | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/flink-clients/src/main/java/org/apache/flink/client/deployment/DefaultClusterClientServiceLoader.java b/flink-clients/src/main/java/org/apache/flink/client/deployment/DefaultClusterClientServiceLoader.java
index 8c33243c1d5..dc95df92c8b 100644
--- a/flink-clients/src/main/java/org/apache/flink/client/deployment/DefaultClusterClientServiceLoader.java
+++ b/flink-clients/src/main/java/org/apache/flink/client/deployment/DefaultClusterClientServiceLoader.java
@@ -52,14 +52,21 @@ public class DefaultClusterClientServiceLoader implements ClusterClientServiceLo
 
         final List<ClusterClientFactory> compatibleFactories = new ArrayList<>();
         final Iterator<ClusterClientFactory> factories = loader.iterator();
-        while (factories.hasNext()) {
+        while (true) {
             try {
+                // hasNext might lead to error in java 24, 25
+                // for more details take a look at https://bugs.openjdk.org/browse/JDK-8196182
+                // and https://bugs.openjdk.org/browse/JDK-8350481
+                if (!factories.hasNext()) {
+                    break;
+                }
                 final ClusterClientFactory factory = factories.next();
                 if (factory != null && factory.isCompatibleWith(configuration)) {
                     compatibleFactories.add(factory);
                 }
             } catch (Throwable e) {
-                if (e.getCause() instanceof NoClassDefFoundError) {
+                if (e instanceof NoClassDefFoundError
+                        || e.getCause() instanceof NoClassDefFoundError) {
                     LOG.info("Could not load factory due to missing dependencies.");
                 } else {
                     throw e;
@@ -98,8 +105,14 @@ public class DefaultClusterClientServiceLoader implements ClusterClientServiceLo
         final List<String> result = new ArrayList<>();
 
         final Iterator<ClusterClientFactory> it = loader.iterator();
-        while (it.hasNext()) {
+        while (true) {
             try {
+                // hasNext might lead to error in java 24, 25
+                // for more details take a look at https://bugs.openjdk.org/browse/JDK-8196182
+                // and https://bugs.openjdk.org/browse/JDK-8350481
+                if (!it.hasNext()) {
+                    break;
+                }
                 final ClusterClientFactory clientFactory = it.next();
 
                 final Optional<String> applicationName = clientFactory.getApplicationTargetName();
@@ -107,7 +120,7 @@ public class DefaultClusterClientServiceLoader implements ClusterClientServiceLo
                     result.add(applicationName.get());
                 }
 
-            } catch (ServiceConfigurationError e) {
+            } catch (ServiceConfigurationError | NoClassDefFoundError e) {
                 // cannot be loaded, most likely because Hadoop is not
                 // in the classpath, we can ignore it for now.
             }