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

Replace code duplicates with closeAllSuppress helper #10682

Merged
merged 2 commits into from
Jan 21, 2022

Conversation

losipiuk
Copy link
Member

No description provided.

@losipiuk
Copy link
Member Author

CI: #10674

Copy link
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

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

Thanks!

{
requireNonNull(rootCause, "rootCause is null");
if (closeables == null) {
return rootCause;
Copy link
Member

Choose a reason for hiding this comment

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

can we require closeables not to be null?

vararg call won't pass null here

Copy link
Member Author

Choose a reason for hiding this comment

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

good point

Copy link
Member Author

Choose a reason for hiding this comment

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

Added some tests too.

@losipiuk losipiuk force-pushed the lo/closables-helper branch 2 times, most recently from e97e06f to 6f24a01 Compare January 20, 2022 11:14
public void testCloseAllSuppressNullClosable()
{
RuntimeException rootException = new RuntimeException("root");
closeAllSuppress(rootException, (AutoCloseable) null);
Copy link
Member Author

Choose a reason for hiding this comment

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

@findepi If I passed just null here (without the cast) it was internally interpreted as whole closeables array and requireNonNull(closeables, "closeables is null") check trigger.
I do not think this is a big deal though. Why would someone use untyped null literal here?

Copy link
Member

Choose a reason for hiding this comment

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

I do not think this is a big deal though. Why would someone use untyped null literal here?

agreed, that would be wrong

@losipiuk losipiuk force-pushed the lo/closables-helper branch from 6f24a01 to 569e4fd Compare January 20, 2022 13:48
@losipiuk losipiuk merged commit aeaf976 into trinodb:master Jan 21, 2022
@github-actions github-actions bot added this to the 369 milestone Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants