SavitarC commented on issue #16295:
URL: https://github.com/apache/dubbo/issues/16295#issuecomment-4603753770
I verified that this issue exists in Dubbo 3.3.6, but it has already been
fixed on the current `3.3` branch.
The fix was introduced by commit
apache/dubbo@3720471e56717b7e3494a7352aa437ef95507fe1, from PR #15754.
The relevant change is in `JsonUtils.loadExtensions()`:
`ServiceLoader.iterator().hasNext()` is now inside the `try/catch`, so optional
JSON providers with missing dependencies can be skipped.
```java
Iterator<JsonUtil> it = loader.iterator();
// In JDK 21+, ServiceLoader.hasNext() may throw NoClassDefFoundError
// when checking class dependencies, so we need to catch it here
while (true) {
try {
if (!it.hasNext()) {
break;
}
JsonUtil extension = it.next();
if (extension.isSupport()) {
if (name != null && name.equals(extension.getName())) {
return extension;
}
extensions.put(extension.getName(), extension);
}
} catch (Throwable ignored) {
// Ignore loading failures (e.g., NoClassDefFoundError in JDK 25)
// and continue with the next extension
}
}
```
I also verified locally that current 3.3 no longer reproduces the issue
without Gson on the classpath.
--
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]