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/08/30 16:51:20 UTC
[PR] [KYUUBI #7688][UTIL] Resolve ctorImpl classes through the builder's configured loader [kyuubi]
LuciferYang opened a new pull request, #7689:
URL: https://github.com/apache/kyuubi/pull/7689
### Why are the changes needed?
Closes #7688.
`DynMethods.Builder.loader(ClassLoader)` configures the loader used for name-based lookups, and `impl(String, ...)` honours it with `Class.forName(className, true, loader)`. `ctorImpl(String, ...)` did not: it built a fresh inner `DynConstructors.Builder`, whose own loader field defaults to `Thread.currentThread().getContextClassLoader()`, and never forwarded the configured one. So `.loader(x).ctorImpl("some.Class")` resolved the name through the context loader rather than through `x`, and when the context loader could not see the class the `ClassNotFoundException` was swallowed as a candidate miss, leaving a generic cannot-find error with no hint that the configured loader had been ignored.
Two things reviewers asked be stated plainly rather than left for someone to discover.
First, `ctorImpl` has no caller anywhere in Kyuubi, only the new test. So this is hygiene on a retained upstream API, not a fixed field bug. Iceberg's answer to the same method was to delete it (in 1.7.0, apache/iceberg#10818); dropping both `ctorImpl` overloads instead of fixing them is a reasonable alternative, and a maintainer call rather than mine.
Second, the fix changes when the default loader is captured. `DynMethods.Builder.loader` is snapshotted at builder construction, whereas the old code snapshotted the context loader at `ctorImpl` call time. A caller that never calls `.loader(...)` but mutates the thread context loader between `DynMethods.builder(...)` and `.ctorImpl(...)` now gets the earlier snapshot. That is already how `impl(String, ...)` behaves, so it makes the class consistent, but it is a behaviour change. Relatedly, a chain ending in `orNoop()` can flip: when the configured and context loaders disagree about a class, whether the chain lands on the real `Ctor` or on the NOOP sentinel reverses, and the two are not interchangeable because `NOOP.bind(receiver)` returns a `BoundMethod` while `Ctor.bind` throws.
The generic `Cannot find method: <name>` message is unchanged by this patch. `ctorImpl` still discards the `problems` map that `DynConstructors` assembles, so a misconfigured loader still surfaces without a root cause. That is pre-existing and left to a follow-up.
### How was this patch tested?
`testCtorImplUsesTheConfiguredLoader` in `DynMethodsTest`, in two halves that fail in opposite directions without the fix.
The first sets the thread context loader to a `URLClassLoader` with a null parent and no URLs, so it can reach no application class, and configures the builder with the app loader. The lookup must succeed. Reverting the production line makes `buildChecked()` throw `NoSuchMethodException: Cannot find method: newInstance` before the assertion is reached.
The second flips them: context loader back to the app loader, builder configured with the blinded loader. The lookup must now fail, which is what pins the absence of a silent fallback. Reverting the fix makes the context loader resolve the class, so `assertThrows` sees nothing thrown.
Both halves set the context loader explicitly rather than relying on the ambient one, and the loader is restored in a `finally` that sits inside the try-with-resources, so it is put back before the `URLClassLoader` is closed.
Ran on Zulu 17.0.18: `build/mvn -o test -pl kyuubi-util -am -DwildcardSuites=none` gives 34/34 green with `DynMethodsTest` at 10 tests, and `build/mvn -o spotless:check -pl kyuubi-util` is clean. The revert-to-red check above was run in a throwaway worktree and reported `Tests run: 34, Failures: 0, Errors: 1`.
### Was this patch assisted by generative AI tooling?
Assisted-by: Claude Opus 5
--
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 #7688][UTIL] Resolve ctorImpl classes through the builder's configured loader [kyuubi]
Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #7689:
URL: https://github.com/apache/kyuubi/pull/7689#discussion_r3931900820
##########
kyuubi-util/src/main/java/org/apache/kyuubi/util/reflect/DynMethods.java:
##########
@@ -343,14 +343,29 @@ public Builder ctorImpl(Class<?> targetClass, Class<?>... argClasses) {
return this;
}
+ /**
+ * Checks for a constructor implementation, first finding the given class by name using this
+ * builder's {@link ClassLoader}.
+ *
+ * <p>Neither upstream copy forwarded the loader to the inner constructor builder, so the name
+ * resolved through the thread context loader regardless of what the caller configured.
+ * parquet-common still resolves it that way; iceberg removed {@code ctorImpl} altogether in
Review Comment:
Dropped, the iceberg link stays. Same reason applies to a clause in #7706's class javadoc that claimed this copy reports candidates unlike either upstream, so I removed that one too.
--
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 #7688][UTIL] Resolve ctorImpl classes through the builder's configured loader [kyuubi]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 closed pull request #7689: [KYUUBI #7688][UTIL] Resolve ctorImpl classes through the builder's configured loader
URL: https://github.com/apache/kyuubi/pull/7689
--
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 #7688][UTIL] Resolve ctorImpl classes through the builder's configured loader [kyuubi]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #7689:
URL: https://github.com/apache/kyuubi/pull/7689#discussion_r3931285596
##########
kyuubi-util/src/main/java/org/apache/kyuubi/util/reflect/DynMethods.java:
##########
@@ -343,14 +343,29 @@ public Builder ctorImpl(Class<?> targetClass, Class<?>... argClasses) {
return this;
}
+ /**
+ * Checks for a constructor implementation, first finding the given class by name using this
+ * builder's {@link ClassLoader}.
+ *
+ * <p>Neither upstream copy forwarded the loader to the inner constructor builder, so the name
+ * resolved through the thread context loader regardless of what the caller configured.
+ * parquet-common still resolves it that way; iceberg removed {@code ctorImpl} altogether in
Review Comment:
> parquet-common still resolves it that way;
state might change over time, and these words will go stale silently, let's drop it the iceberg change link is sufficient for us to track the upstream change.
--
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 #7688][UTIL] Resolve ctorImpl classes through the builder's configured loader [kyuubi]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #7689:
URL: https://github.com/apache/kyuubi/pull/7689#issuecomment-5536367008
PR description is too long for such a change, can you make it shorter?
--
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 #7688][UTIL] Resolve ctorImpl classes through the builder's configured loader [kyuubi]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #7689:
URL: https://github.com/apache/kyuubi/pull/7689#discussion_r3931285596
##########
kyuubi-util/src/main/java/org/apache/kyuubi/util/reflect/DynMethods.java:
##########
@@ -343,14 +343,29 @@ public Builder ctorImpl(Class<?> targetClass, Class<?>... argClasses) {
return this;
}
+ /**
+ * Checks for a constructor implementation, first finding the given class by name using this
+ * builder's {@link ClassLoader}.
+ *
+ * <p>Neither upstream copy forwarded the loader to the inner constructor builder, so the name
+ * resolved through the thread context loader regardless of what the caller configured.
+ * parquet-common still resolves it that way; iceberg removed {@code ctorImpl} altogether in
Review Comment:
> parquet-common still resolves it that way;
state might change over time, and these words will go stale silently, let's drop it, and the iceberg change link is sufficient for us to track the upstream change.
--
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 #7688][UTIL] Resolve ctorImpl classes through the builder's configured loader [kyuubi]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #7689:
URL: https://github.com/apache/kyuubi/pull/7689#issuecomment-5536435087
**Merge Summary:**
- merged into master https://github.com/apache/kyuubi/commit/9cd300b87919e65799910244ebb666a3555be53f
- merged into branch-1.12 https://github.com/apache/kyuubi/commit/f93d229ce53436d482cabe0212b60e69f234786f
*Posted by `merge_kyuubi_pr.py`*
--
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 #7688][UTIL] Resolve ctorImpl classes through the builder's configured loader [kyuubi]
Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on PR #7689:
URL: https://github.com/apache/kyuubi/pull/7689#issuecomment-5537287353
Trimmed to about half the length: the loader bug, the change in when the default loader is captured, and that `ctorImpl` has no caller here so deleting both overloads is an option. Dropped the `orNoop()` flip that the capture change can cause and the note about the generic `Cannot find method` message, which #7706 covers.
--
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