Skip to content

[KYUUBI #7731][UTIL] Stop re-labeling invocation failures as missing members in ReflectUtils - #7732

Open
LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:kyuubi-util-scala-reflectutils-errormessage
Open

[KYUUBI #7731][UTIL] Stop re-labeling invocation failures as missing members in ReflectUtils#7732
LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:kyuubi-util-scala-reflectutils-errormessage

Conversation

@LuciferYang

Copy link
Copy Markdown
Contributor

Why are the changes needed?

Closes #7731.

ReflectUtils.getField and invokeAs wrapped the whole body in one try and rewrote any Exception as RuntimeException(s"$clz does not have ...", e). Because bind/get/invoke ran inside that same try, a failure thrown by the found field or the invoked method itself was relabeled as a missing member, and the real exception survived only as the cause.

This moves the try/catch to wrap only the lookup (DynFields/DynMethods build/buildChecked). The "does not have" message now applies only when the lookup fails; a failure while binding, reading, or invoking the found member keeps its own type and message.

How was this patch tested?

Added two ReflectUtilsSuite cases: an invoked method that throws IllegalArgumentException("bad input") must propagate that exception rather than a "does not have" message, and binding a Class target to an instance field must surface the field wrapper's "Cannot bind" IllegalArgumentException. Both fail if the catch is widened back over the invocation.

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

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.

ReflectUtils re-labels invocation and bind failures as missing members

1 participant