-
Notifications
You must be signed in to change notification settings - Fork 7
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
NullPointerException in equals(), hashCode() and toString() with @Nullable Vector. #34
Comments
I tried to see if I could fix it and send up a PR, but I don't see where you've done anything custom to support toString(), equals() or hashCode() so I didn't know how to proceed and am less certain if the issue is from this jar. Maybe you need to add something specific to handle those methods? I don't know. |
Thank you for reporting this. I definitely want to somehow address the issue, but it might not be easy due to certain limitation we have (regarding annotation matching and handling). It should be possible to customize Just as workaround, if you use Vavr it might be more natural to use On the second thought, it might be even possible (I honestly don't remember if it will work for sure, but...) to create separate encoding for type combination like @Encoding
class OptionalVectorEncoding<T> {
@Encoding.Impl
private Option<Vector<T>> field = Option.none();
...
// and then builder which would define `addXx` method by smth like
// case none -> some(Vector.of(param))
// case some(v) -> some(v.append(param))`
} That example is probably for creating encoding for your own needs, I don't know if those belong to this library of basic vavr encodings. |
Here's example I found of similar, but probably more involved implementation of the encoding for combined types (apparently those are actually working) https://github.com/Discord4J/discord-json/blob/master/encoding/src/main/java/discord4j/discordjson/possible/PossibleListEncoding.java |
I am creating an Immutable POJO object which needs to support an
@Nullable
Vector and the toString(), equals() and hashCode() methods are throwing NPEs because they assume the vector will never be null.Most of the time this isn't an issue because I don't let the Vectors be nullable, but I now have a situation where it is not avoidable. I have worked around it by overriding those three methods, but this is something that I feel should be fixed in the "org.immutables.vavr:vavr-encodings" artifact (i.e. this project).
Thanks for all you do.
The text was updated successfully, but these errors were encountered: