LuciferYang opened a new issue, #7723:
URL: https://github.com/apache/kyuubi/issues/7723
### Describe the bug
`ReflectUtils.isClassLoadable` probes a class through `DynClasses`, wrapped
in `scala.util.Try`:
```scala
def isClassLoadable(
className: String,
cl: ClassLoader = Thread.currentThread().getContextClassLoader): Boolean
=
Try {
DynClasses.builder().loader(cl).impl(className).buildChecked()
}.isSuccess
```
`DynClasses.impl` resolves the name with `Class.forName(className, true,
loader)`. `initialize = true` means loading the class also links it and runs
its static initializer, so a class that is present but fails at that stage
raises a `LinkageError`, not a `ClassNotFoundException`: `NoClassDefFoundError`
for a missing superclass or dependency, `ExceptionInInitializerError` when a
static initializer throws.
`Try` only catches `NonFatal`, and `LinkageError` is excluded from
`NonFatal`. So a class that fails to link or initialize never reaches
`.isSuccess`; the `LinkageError` escapes `isClassLoadable` and crashes the
caller. A loadability probe should answer `false` for such a class, not throw.
Both call sites treat the result as a feature-detection boolean and never
expect an exception:
- `Logging.scala:152`: `if
(ReflectUtils.isClassLoadable("org.slf4j.bridge.SLF4JBridgeHandler"))`
- `JDBCMetadataStore.scala:51`: `if
(ReflectUtils.isClassLoadable("com.mysql.cj.jdbc.Driver"))`
A probed class that is on the classpath but whose static initializer throws
(a misconfigured dependency, say) aborts the check instead of being reported as
not loadable.
The `Try` wrapping came in with the reflection-utility consolidation
(#4887); nothing there depended on a `LinkageError` propagating.
### Affects Version(s)
master (1.13.0-SNAPSHOT), and earlier releases carrying `kyuubi-util-scala`.
### Are you willing to submit PR?
Yes.
--
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]