-
Notifications
You must be signed in to change notification settings - Fork 458
[FLUSS-2091][common] Introduced Cycle Detection During Exception Suppression #2112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces cycle detection during exception suppression to prevent StackOverflowError that can occur when cascading exceptions create cycles in the suppression or cause chains. The fix mirrors a similar solution already implemented in Apache Flink and addresses issue #2091.
Key Changes:
- Added cycle detection logic to
ExceptionUtils.firstOrSuppressed()to prevent circular references in exception chains - Introduced a new private helper method
existsInExceptionChain()that performs graph-based traversal of both suppression and cause chains to detect cycles - Added comprehensive test coverage to validate cycle prevention behavior
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| fluss-common/src/main/java/org/apache/fluss/utils/ExceptionUtils.java | Added cycle detection logic in firstOrSuppressed() and new existsInExceptionChain() helper method with graph-based traversal using HashSet and Deque |
| fluss-common/src/test/java/org/apache/fluss/utils/ExceptionUtilsTest.java | Fixed typo in comment and added testFirstOrSuppressedCyclePrevention() test to validate cycle prevention in suppressed exception chains |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fluss-common/src/test/java/org/apache/fluss/utils/ExceptionUtilsTest.java
Show resolved
Hide resolved
fluss-common/src/main/java/org/apache/fluss/utils/ExceptionUtils.java
Outdated
Show resolved
Hide resolved
fluss-common/src/main/java/org/apache/fluss/utils/ExceptionUtils.java
Outdated
Show resolved
Hide resolved
| * @param exception The throwable exception to search for. | ||
| * @param previous The previous throwable exception chain to search in. |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter names in the javadoc don't accurately describe their semantics. The parameter named exception is described as "The throwable exception to search for" and previous is described as "The previous throwable exception chain to search in". However, these names suggest temporal ordering rather than the search relationship. Consider renaming them to something like searchTarget and chainToSearch or needle and haystack to better convey that this is a search operation, or update the description to clarify the purpose more explicitly.
fluss-common/src/main/java/org/apache/fluss/utils/ExceptionUtils.java
Outdated
Show resolved
Hide resolved
fluss-common/src/test/java/org/apache/fluss/utils/ExceptionUtilsTest.java
Outdated
Show resolved
Hide resolved
[FLUSS-2091][common] Added Exception Cycle Tests for Cause-Chain Cases
… Cases [FLUSS-2091][common] Replaced Assertion Syntax for Exception-Handling Cases
|
This has been fixed in Flink, close this PR. See comments in the issue. |
Purpose
Linked issue: close #2091
Per Issue #2091, this pull request attempts to address an issue that could result in a
StackOverflowErrorstemming from a cycle of cascading exceptions that originally stem from Flink'sSerializedThrowablehandler. This fix has already been made within Flink in this commit which should prevent the behavior (see discussion here for more context).Brief change log
This change introduces a new private functions within the
ExceptionUtilsclass to support exception chain evaluation for suppression and cause chains (existsInExceptionChain). This function is applied during thefirstOrSuppressedfunction call, which introduces a new exception to the existing chain, and traverses both the suppression and cause chains using a graph to evaluate for existence.Tests
The
ExceptionTestUtils.testFirstOrSuppressedCyclePreventionwas initially updated to use an arbitrary recursive exception call to mimic Flink's existingSerializedThrowableto reproduce the original issue (triggering aStackOverflowError). This test was later updated after the fix was applied to ensure that these previous exceptions no longer result in a cycle being created.API and Format
N/A
Documentation
N/A