juliuszsompolski commented on code in PR #54007:
URL: https://github.com/apache/spark/pull/54007#discussion_r2732262114
##########
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(
+ wrapper.belowStacktrace ++
Thread.currentThread().getStackTrace.drop(1))
Review Comment:
if going ahead with it, you don't need to store belowStacktrace at all, only
the prefix length. The below part is already in originalEx, and is not
changing, only the suffix of the current caller changes.
So
```
val belowStacktraceLength = origStackTrace.size - commonSuffixLen
```
in `doTryWithCallerStacktrace` and here
```
originalEx.setStackTrace(
orignalEx.take(belowStacktraceLength) ++
Thread.currentThread().getStackTrace.drop(1))
```
should work.
--
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]