juliuszsompolski commented on code in PR #54007:
URL: https://github.com/apache/spark/pull/54007#discussion_r2732285608


##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -1424,32 +1421,19 @@ private[spark] object Utils
    * below the original doTryWithCallerStacktrace which triggered it, with the 
caller stack trace
    * of the current caller of getTryWithCallerStacktrace.
    *
-   * Full stack trace of the original doTryWithCallerStacktrace caller can be 
retrieved with
-   * ```
-   * ex.getSuppressed.find { e =>
-   *   e.isInstanceOf[Utils.OriginalTryStackTraceException]
-   * }
-   * ```
-   *
-   *
    * @param t Try from doTryWithCallerStacktrace
    * @return Result of the Try or rethrows the failure exception with modified 
stacktrace.
    */
   def getTryWithCallerStacktrace[T](t: Try[T]): T = t match {
+    case Failure(wrapper: OriginalTryStackTraceException) =>
+      // Unwrap to get the original exception
+      val originalEx = wrapper.getCause
+      // Stitch the stacktrace: keep the "below" part, replace "above" with 
current caller
+      originalEx.setStackTrace(

Review Comment:
   The suppressed Exception is not ideal, because it's more the "cause", but we 
cannot make it the cause, because the original exception might have already 
been the cause... Having it as suppressed exception was the only way I could 
find to tag it along without disrupting the original exception...



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