LuciferYang opened a new pull request, #7641:
URL: https://github.com/apache/kyuubi/pull/7641

   ### Why are the changes needed?
   
   Fix #7640.
   
   `UnboundMethod.invoke` unwrapped exceptions twice: `invokeChecked` already 
throws the real exception produced by the invoked method, but `invoke` re-threw 
`e.getCause()` as if `e` were still the `InvocationTargetException`. 
Consequences:
   
   - an exception without a cause degraded to `new RuntimeException(null)` — 
the type, message and stack trace of the real failure were all lost;
   - a `RuntimeException` carrying a cause was silently replaced by that cause, 
so `catch (IllegalStateException)` at a call site missed an 
`IllegalStateException` thrown by the target.
   
   The fix re-throws `RuntimeException` as-is and wraps checked exceptions with 
the real exception as cause, matching the sibling 
`DynConstructors.Ctor.newInstance` and restoring the semantics both upstreams 
always had (parquet-common, unchanged since PARQUET-777; Iceberg) and that were 
lost during vendoring in db0047d51 ([KYUUBI #3230]).
   
   All in-repo `.invoke`/`.invokeChecked` call sites were audited: none depends 
on the old behavior. Callers going through `ReflectUtils.invokeAs` keep their 
top-level message but now carry the real cause; direct users of the wrappers 
(`EmbeddedExecutorFactory`, `KyuubiSparkUtil`, `EngineTab`, `RowSet`) now see 
the real exception type and message.
   
   ### How was this patch tested?
   
   Added `DynMethodsTest`, the first unit tests for 
`org.apache.kyuubi.util.reflect`: 9 cases covering both failure modes of the 
old code, a causeless-`RuntimeException` identity pin (`assertSame`), a 
checked-exception-carrying-runtime-cause pin, the `BoundMethod`/`StaticMethod` 
wrappers, fixed-arity and varargs happy paths, and the `invokeChecked` contract.
   
   Verified RED→GREEN: with the production fix reverted, 6 of the 9 cases fail 
(the regression pins); with the fix applied, all pass.
   
   ```
   build/mvn test -pl kyuubi-util -am          # 18/18 pass
   build/mvn spotless:check -pl kyuubi-util    # pass
   ```
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Assisted-by: ZCode with GLM-5.3 (fix authoring, verification, review loop)
   Assisted-by: Claude Opus (test hardening review round)
   
   The human author reviewed every line of the patch.
   


-- 
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]

Reply via email to