Skip to content
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

fix: avoid recursive Throwable cause chains #1255

Merged
merged 3 commits into from
May 18, 2021

Conversation

lemnik
Copy link
Contributor

@lemnik lemnik commented May 17, 2021

Goal

Avoid errors caused by Throwable.cause chains that are recursive (self-referencing).

Design

Added a method to unroll the cause-chain into a flat List and handle any recursion.

Testing

Added RecursiveThrowableCauseTest to test code that previously had recursion problems, and UnrollThrowableCausesTest to test the contract of the new unroll method.

@lemnik lemnik force-pushed the PLAT-6557/fix-recursive-cause-chains branch from 440c506 to 44de572 Compare May 17, 2021 13:01
Copy link
Contributor

@fractalwrench fractalwrench left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending one minor comment.

} else {
return getRootCause(cause);
}
List<Throwable> causes = ThrowableExtensionsKt.safeUnrollCauses(throwable);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your suggestion of using @file:JvmName("ThrowableUtils") to rename the file would work well here.

@lemnik lemnik merged commit 8cd07d0 into next May 18, 2021
@lemnik lemnik deleted the PLAT-6557/fix-recursive-cause-chains branch May 18, 2021 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants