Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Exception to deserialize 'com.spotify.docker.client.messages.Event' #584
I'm trying to serialize events from Docker to send for a monitoring tool. I can serialized an event to json, but when I try to deserialize arise an exception :
How to reproduce
What do you expect
I expect something like this:
What happened instead
It looks to me like the problem is that we have a custom deserializer class for the
In fact, this same behavior would happen on any object -> json -> object round trip if the object has a
To fix this, we would need to create a serializer class that takes
I agree that it would make sense for the Event class, if it has a custom deserializer for the date field, to also attach serializer too, just in case anyone wants to go from Object -> JSON.
On the other hand, as a workaround, anyone trying to serialize these Events back to JSON could add their own serializer or customize the ObjectMapper instance themselves - I am surprised anyone would want to use the same ObjectMapperProvider we use internally.
@mattnworb I'm using the same ObjectMapperProvider because I don't want need to implement a new one by myself. As the API have an object mapper why not use it?
I solved the problem by creating a custom DateSerializer as below:
Thus, I just need to register MyDateSerializer for correctly desserialize an Event by using the native ObjectMapperProvider:
All are working fine now!