You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 22, 2019. It is now read-only.
This is kind of a strange issue, which I can't really describe well except by the unit test below. When a Guava Optional wraps a generic type (eg. a Collection), the generic type information seems to be lost somewhere along the way, and the visitor does not actually visit the properties of the generic type.
In the following code, the test fails using 2.6.0-rc3 and higher (2.6.2 included), but succeeds with 2.6.0-rc2. The expected output is [values.data, values, values.data.value], but the actual output is [values.data, values].
While debugging, I found out that in the method GuavaOptionalSerializer#acceptJsonFormatVisitor the generic type information of Collection is lost, and it thinks the type is Object, not ValueHolder, but the code was a bit too complex for me to figure out why or how. It seems to me the issue might have been in changeset eb6b98a but I'm not sure.
By the way, this works fine with Jdk8Module and java.util.Optional.
This does sound complicated, thank you for reporting it.
I am not sure whether expected behavior can be fully supported because generic parameters for "custom" types (that is, something other than parameterization of recognized types like Map, Collection, Iterable, Optional)) are difficult to handle and pass; and the reason earlier versions worked may actually have been lucky coincidence. But I hope I am wrong and it turns out it can be supported just fine. :-)
Thank you for the test -- problem was actually easy enough to solve; serializer access was not using full JavaType, but type-erased (raw) version. Fix will be in 2.6.3.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
This is kind of a strange issue, which I can't really describe well except by the unit test below. When a Guava Optional wraps a generic type (eg. a
Collection
), the generic type information seems to be lost somewhere along the way, and the visitor does not actually visit the properties of the generic type.In the following code, the test fails using
2.6.0-rc3
and higher (2.6.2
included), but succeeds with2.6.0-rc2
. The expected output is[values.data, values, values.data.value]
, but the actual output is[values.data, values]
.While debugging, I found out that in the method
GuavaOptionalSerializer#acceptJsonFormatVisitor
the generic type information ofCollection
is lost, and it thinks the type isObject
, notValueHolder
, but the code was a bit too complex for me to figure out why or how. It seems to me the issue might have been in changeset eb6b98a but I'm not sure.By the way, this works fine with
Jdk8Module
andjava.util.Optional
.The text was updated successfully, but these errors were encountered: