rionmonster commented on code in PR #2112:
URL: https://github.com/apache/fluss/pull/2112#discussion_r2643356308
##########
fluss-common/src/test/java/org/apache/fluss/utils/ExceptionUtilsTest.java:
##########
@@ -121,6 +122,35 @@ void testFirstOrSuppressed() {
assertThat(suppressedException.getSuppressed()).isEqualTo(new
Throwable[] {newException});
}
+ @Test
+ void testFirstOrSuppressedCyclePrevention() {
+ // create two test exceptions (assuming thrown during shutdown, etc.)
+ Exception exceptionA = new Exception("Exception A");
+ Exception exceptionB = new Exception("Exception B");
+
+ // associate the suppressions (creating a suppression chain)
+ ExceptionUtils.firstOrSuppressed(exceptionB, exceptionA);
+ assertThat(exceptionA.getSuppressed()).contains(exceptionB);
+
+ // attempt to create a suppression cycle (A -> B; B -> A)
+ Exception result = ExceptionUtils.firstOrSuppressed(exceptionA,
exceptionB);
+ assertThat(result).isEqualTo(exceptionB);
+
+ // verify the exception cycle was prevented (no bidirectional
reference)
+ assertThat(exceptionA.getSuppressed()).contains(exceptionB);
+ assertThat(exceptionB.getSuppressed()).doesNotContain(exceptionA);
+ assertThat(exceptionB.getSuppressed()).isEmpty();
+
+ // verify that processing suppressed exceptions no longer causes
StackOverflowError
+ Assertions.assertDoesNotThrow(() ->
recursivelyProcessSuppressedExceptions(exceptionA));
+ }
Review Comment:
This is a good call out -- I've addressed this.
--
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]