Skip to content

Allow nullable types in Flow's firstOrNull extension #2230

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

Closed
wants to merge 3 commits into from

Conversation

ansman
Copy link
Contributor

@ansman ansman commented Sep 4, 2020

This closes #2229

@qwwdfsad qwwdfsad self-requested a review September 24, 2020 10:24
Copy link
Collaborator

@qwwdfsad qwwdfsad left a comment

Choose a reason for hiding this comment

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

Thanks!

Could you please also remove Any upper bound from singleOrNull operator and add a corresponding unit test?

@ansman
Copy link
Contributor Author

ansman commented Sep 24, 2020

Done

@qwwdfsad qwwdfsad self-requested a review October 5, 2020 17:12
Copy link
Collaborator

@qwwdfsad qwwdfsad left a comment

Choose a reason for hiding this comment

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

assertFailsWith<NoSuchElementException> { flowOf<Int?>().singleOrNull() } doesn't actually fail but returns null instead. Added test doesn't pass

@ansman
Copy link
Contributor Author

ansman commented Oct 5, 2020

My bad. I'm unable to run the tests locally because java 6 is needed.

@LouisCAD
Copy link
Contributor

LouisCAD commented Oct 6, 2020

@ansman Read the updated CONTRIBUTING.md on the main/master branch, it's specified you can make the env variable point to a newer JDK, including JDK11+

@qwwdfsad qwwdfsad self-requested a review October 7, 2020 09:15
@qwwdfsad qwwdfsad mentioned this pull request Oct 7, 2020
Copy link
Collaborator

@qwwdfsad qwwdfsad left a comment

Choose a reason for hiding this comment

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

Multiple null values are handled incorrectly.
I've created #2287 with your changes and fixed it in 7d006bb to reduce a rountrip time and merge it.

Thanks for raising the issue and your contribution, it's always great to evolve our API based on our users feedback!

@qwwdfsad qwwdfsad closed this Oct 7, 2020
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.

Flow.firstOrNull should allow nullable types
4 participants