Skip to content

Conversation

@RishiMenpara
Copy link

Rationale for this change

This PR addresses the issue where running Apache Dubbo on JDK 25 could lead to a fatal NoClassDefFoundError or other Throwables during the ServiceLoader iteration process within JsonUtils.java. This incompatibility arises from behavioral changes in the java.util.ServiceLoader API in recent JDK versions, where Iterator.hasNext() can now throw exceptions when attempting to load a service provider that has missing dependencies.

What is the effect of this change?

Without this fix, users running on JDK 25 (especially those not using a JSON framework that Dubbo expects) will experience application startup failure.

Detailed Fix

The loadExtensions() method in JsonUtils has been refactored from a for loop to a safe while(true) loop. This allows both the it.hasNext() and it.next() calls to be wrapped in a single try-catch (Throwable) block, safely skipping any broken service provider definitions without crashing the entire iteration process.

Related Issue

Closes #15747

Updated loadExtensions method to improve JDK 25 compatibility by restructuring the loop to handle exceptions from ServiceLoader safely.
Refactor loadExtensions method for JDK 25 compatibility and improve exception handling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] JDK 25's ServiceLoader iterator may throw exception in hasNext

1 participant