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

Xor.Right.right() should return Optional.ofNullable(right) #308

Open
JimSermersheim opened this issue Aug 1, 2023 · 1 comment
Open

Comments

@JimSermersheim
Copy link

JimSermersheim commented Aug 1, 2023

I have a minion function that can in some conditions return None.
When this happens, the Result element for the minion is a Result(null) -- in other words, The Result's xor is a Right, where the right value is null. Calling Result.result() causes a NullPointerException because Xor.Right.right() is returning Optional.of(right). Since it's returning an Optional, it seems like it'd be better to return Optional.ofNullable(right).

The same would probably apply to Xor.Left.left(), though I can't think of the use case where the value there would be null.

@JimSermersheim
Copy link
Author

Workaround: don't' call Result.result(). Instead, use Result.consume(). The consumerResult will be given a null object for the case in the description

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

No branches or pull requests

1 participant