@@ -383,35 +383,37 @@ public static <T extends Throwable> T firstOrSuppressed(T newException, @Nullabl
383383 }
384384
385385 /**
386- * Checks whether the given {@code exception} throwable exception exists anywhere within the
387- * exception chain of {@code previous }. This includes both the cause chain and all suppressed
388- * exceptions. A visited set is used to avoid cycles and redundant traversal.
386+ * Checks whether the given {@code targetException} exists anywhere within the exception chain
387+ * of {@code exceptionChain }. This includes both the cause chain and all suppressed exceptions.
388+ * A visited set is used to avoid cycles and redundant traversal.
389389 *
390- * @param exception The throwable exception to search for.
391- * @param previous The previous throwable exception chain to search in.
392- * @return True, if the exception is found within the suppressed chain, false otherwise.
390+ * @param targetException The throwable exception to search for.
391+ * @param exceptionChain The previous throwable exception chain to search in.
392+ * @return {@code true}, if the exception is found within the exception chain (suppressed or
393+ * cause), {@code false} otherwise.
393394 */
394- private static boolean existsInExceptionChain (Throwable exception , Throwable previous ) {
395- if (exception == null || previous == null ) {
395+ private static boolean existsInExceptionChain (
396+ Throwable targetException , Throwable exceptionChain ) {
397+ if (targetException == null || exceptionChain == null ) {
396398 return false ;
397399 }
398- if (exception == previous ) {
400+ if (targetException == exceptionChain ) {
399401 return true ;
400402 }
401403
402404 // Apply cycle prevention through a graph-like traversal of existing
403405 // suppressed or cause chain exceptions
404- Set <Throwable > previousExceptions = new HashSet <>();
406+ Set <Throwable > visitedExceptions = new HashSet <>();
405407 Deque <Throwable > exceptionStack = new ArrayDeque <>();
406- exceptionStack .push (previous );
408+ exceptionStack .push (exceptionChain );
407409
408410 while (!exceptionStack .isEmpty ()) {
409411 Throwable currentException = exceptionStack .pop ();
410- if (!previousExceptions .add (currentException )) {
412+ if (!visitedExceptions .add (currentException )) {
411413 continue ;
412414 }
413415
414- if (currentException == exception ) {
416+ if (currentException == targetException ) {
415417 return true ;
416418 }
417419
0 commit comments