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

Return Result.ok(null) #47

Open
prokoks121 opened this issue Oct 22, 2024 · 1 comment
Open

Return Result.ok(null) #47

prokoks121 opened this issue Oct 22, 2024 · 1 comment

Comments

@prokoks121
Copy link

If I want to return Result.ok and enter null as a value, for certain methods such as isOk, ifOk and similar, a nullPointerException is obtained.

java.lang.NullPointerException: null
at java.base/java.util.Objects.requireNonNull(Objects.java:233) ~[na:na]
at java.base/java.util.Optional.of(Optional.java:113) ~[na:na]
at com.hubspot.algebra.Results.lambda$getOk$3(Results.java:46) ~[algebra-1.5.jar:1.5]
at com.hubspot.algebra.Results$Ok.match(Results.java:104) ~[algebra-1.5.jar:1.5]
at com.hubspot.algebra.Results.getOk(Results.java:45) ~[algebra-1.5.jar:1.5]
at com.hubspot.algebra.Result.isOk(Result.java:32) ~[algebra-1.5.jar:1.5]

@prokoks121
Copy link
Author

Additional
isOk throw exception because it uses :
/**
* Returns an {@code Optional} describing the given non-{@code null}
* value.
*
* @param value the value to describe, which must be non-{@code null}
* @param the type of the value
* @return an {@code Optional} with the value present
* @throws NullPointerException if value is {@code null}
*/
public static Optional of(T value) {
return new Optional<>(Objects.requireNonNull(value));
}

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