Skip to content

Conversation

@cloud-fan
Copy link
Contributor

@cloud-fan cloud-fan commented Jan 27, 2026

What changes were proposed in this pull request?

This PR refactors how doTryWithCallerStacktrace and getTryWithCallerStacktrace handle stacktrace stitching. Instead of adding an OriginalTryStackTraceException as a suppressed exception on the original exception, we now wrap the original exception inside OriginalTryStackTraceException.

Key changes:

  • OriginalTryStackTraceException now wraps the original exception (as its cause) and stores the pre-computed "below" stacktrace portion
  • doTryWithCallerStacktrace returns Failure(wrapper) instead of modifying the original exception's suppressed list
  • getTryWithCallerStacktrace unwraps the original exception, stitches the stacktrace, and throws the original (not the wrapper)

Why are the changes needed?

no suppressed exceptions visible to users

Does this PR introduce any user-facing change?

Yes, exceptions thrown from LazyTry.get will no longer have a suppressed OriginalTryStackTraceException. The stacktrace stitching behavior remains the same.

How was this patch tested?

Existing unit tests in UtilsSuite and LazyTrySuite updated and passing.

Was this patch authored or co-authored using generative AI tooling?

Yes.

…er instead of suppressed exception

This PR refactors how `doTryWithCallerStacktrace` and `getTryWithCallerStacktrace` handle stacktrace stitching. Instead of adding an `OriginalTryStackTraceException` as a suppressed exception on the original exception, we now wrap the original exception inside `OriginalTryStackTraceException`.

Key changes:
- `OriginalTryStackTraceException` now wraps the original exception (as its cause) and stores the pre-computed "below" stacktrace portion
- `doTryWithCallerStacktrace` returns `Failure(wrapper)` instead of modifying the original exception's suppressed list
- `getTryWithCallerStacktrace` unwraps the original exception, stitches the stacktrace, and throws the original (not the wrapper)

Benefits:
- Cleaner exception output - no suppressed exceptions visible to users
- Simpler code - no need to track first access or manage suppressed exception lifecycle
- Original exception type is preserved when thrown
@github-actions github-actions bot added the CORE label Jan 27, 2026
@github-actions
Copy link

github-actions bot commented Jan 27, 2026

JIRA Issue Information

=== Improvement SPARK-55240 ===
Summary: Refactor LazyTry stacktrace handling to use wrapper instead of suppressed exception
Assignee: None
Status: Open
Affected: ["4.2.0"]


This comment was automatically generated by GitHub Actions

@codecov-commenter
Copy link

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

@cloud-fan cloud-fan changed the title [SPARK-XXXXX][CORE] Refactor LazyTry stacktrace handling to use wrapper instead of suppressed exception [SPARK-55240][CORE] Refactor LazyTry stacktrace handling to use wrapper instead of suppressed exception Jan 27, 2026
@cloud-fan
Copy link
Contributor Author

This is kind of followup of #48882

cc @juliuszsompolski @yaooqinn

@cloud-fan cloud-fan closed this Jan 27, 2026
@cloud-fan cloud-fan deleted the error branch January 27, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants