Skip to content

Core: Fix NPE in CloseableIterable.close()#6322

Merged
danielcweeks merged 1 commit into
apache:masterfrom
nastra:closeable-iterable-npe-fix
Dec 1, 2022
Merged

Core: Fix NPE in CloseableIterable.close()#6322
danielcweeks merged 1 commit into
apache:masterfrom
nastra:closeable-iterable-npe-fix

Conversation

@nastra
Copy link
Copy Markdown
Contributor

@nastra nastra commented Nov 30, 2022

This can be reproduced by running:

CloseableIterable<Object> closeableIterable = CloseableIterable.concat(Collections.emptyList());
closeableIterable.iterator();
// throws a NPE here
closeableIterable.close();

@findepi
Copy link
Copy Markdown
Member

findepi commented Nov 30, 2022

@nastra thank you for the fix.

Note that build isn't green

@nastra
Copy link
Copy Markdown
Contributor Author

nastra commented Nov 30, 2022

@nastra thank you for the fix.

Note that build isn't green

This is because CI is currently broken and will be fixed by #6314

@nastra nastra force-pushed the closeable-iterable-npe-fix branch from d4dadff to e379c8b Compare November 30, 2022 15:50
}

@Test
public void concatIterablesWithIterator() throws IOException {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: this method name can be more descriptive, sth like testCloseWithEmptyIterables

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I specifically avoid naming it like this, because the important piece where this NPE is happening is the usage of .iterator() before doing a .close()

@danielcweeks danielcweeks merged commit b202dff into apache:master Dec 1, 2022
@nastra nastra deleted the closeable-iterable-npe-fix branch December 1, 2022 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants