LuciferYang opened a new issue, #7731:
URL: https://github.com/apache/kyuubi/issues/7731

   ### Describe the bug
   
   `ReflectUtils.getField` and `invokeAs` wrap the whole body in one `try` and 
rewrite any `Exception` into a missing-member message:
   
   ```scala
   def invokeAs[T](target: AnyRef, methodName: String, args: (Class[_], 
AnyRef)*): T = {
     val (clz, obj) = getTargetClass(target)
     val argClasses = args.map(_._1)
     try {
       val method = DynMethods.builder(methodName)
         .hiddenImpl(clz, argClasses: _*)
         .impl(clz, argClasses: _*)
         .buildChecked
       if (method.isStatic) {
         method.asStatic.invoke[T](args.map(_._2): _*)
       } else {
         method.bind(obj).invoke[T](args.map(_._2): _*)
       }
     } catch {
       case e: Exception =>
         throw new RuntimeException(
           s"$clz does not have 
$methodName${argClasses.map(_.getName).mkString("(", ", ", ")")}",
           e)
     }
   }
   ```
   
   The `catch` covers more than the lookup. Once `buildChecked` has found the 
method, `invoke` runs inside the same `try`, so an exception thrown by the 
invoked method itself is relabeled `"$clz does not have $methodName(...)"`, a 
missing-member message for a member that was found and ran. `getField` has the 
same shape: a failure while binding or reading the found field is reported as a 
missing field. The real exception survives only as the wrapper's cause.
   
   That points a reader at a lookup problem that does not exist. These helpers 
reflect into Spark and Hive internals, so when a called method throws (a bad 
argument, an illegal state), the failure reads as if the method were missing.
   
   ### 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]

Reply via email to