You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by "LuciferYang (via GitHub)" <gi...@apache.org> on 2026/09/10 17:17:04 UTC
[PR] [KYUUBI #7733][UTIL] Fall back to ReflectUtils's own loader when the context loader is null [kyuubi]
LuciferYang opened a new pull request, #7734:
URL: https://github.com/apache/kyuubi/pull/7734
### Why are the changes needed?
Closes #7733.
Stacked on #7724; its commit is the first of the two here, and the diff reduces to the second commit once #7724 merges.
`ReflectUtils.isClassLoadable` defaults its loader to the thread context classloader. On a thread whose context loader is null, `DynClasses.builder().loader(null)` resolves the name through `Class.forName(name, true, null)`, which delegates to the bootstrap loader. The bootstrap loader sees only JDK classes, so the probe answers `false` for every application class, including Kyuubi's own, even when it is loadable through the loader that defined `ReflectUtils`.
This falls back to `ReflectUtils`'s own classloader when the effective loader is null, matching Spark's `getContextOrSparkClassLoader`. The change is monotonic: a non-null loader behaves exactly as before, and a null loader can only turn a `false` into a `true` (an application class becomes loadable), never the reverse. Repository threads carry a non-null context loader under normal startup, so this is defensive hardening for embedded hosts (a JNI invocation that never sets a context loader, a container framework that clears it) and third-party callers of this public helper.
### How was this patch tested?
Added a `ReflectUtilsSuite` case that sets the thread context loader to null (restored in `finally`) and asserts an application class is loadable while a non-existent one is not. It fails without the fallback, since the bootstrap loader cannot see the class.
```
build/mvn test -pl kyuubi-util-scala -am
build/mvn scalastyle:check spotless:check -pl kyuubi-util-scala -am
```
Module green on Zulu 17.0.18 (23/23), scalastyle 0 errors, spotless clean.
### Was this patch assisted by generative AI tooling?
Assisted-by: Claude Opus 4.8
--
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: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
Re: [PR] [KYUUBI #7733][UTIL] Fall back to ReflectUtils's own loader when the context loader is null [kyuubi]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #7734:
URL: https://github.com/apache/kyuubi/pull/7734#issuecomment-6413692011
sorry for the late, could you rebase to resolve conflicts?
--
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: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org