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

Use custom deserialization to handle list extensions #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joshbooks
Copy link
Contributor

@joshbooks joshbooks commented Apr 17, 2020

intended to fix #7

@joshbooks
Copy link
Contributor Author

@nitram22 mind taking a look when you have a minute?

@nitram22
Copy link
Contributor

nitram22 commented Apr 22, 2020

When I just tested it, the CertstreamCertificatePOJODeserializer threw a StackOverflow error.

Stacktrace:

Exception in thread "WebSocketConnectReadThread-18" java.lang.StackOverflowError at com.google.gson.internal.bind.JsonTreeReader.nextString(JsonTreeReader.java:178) at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:702) at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:723) at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:698) at com.google.gson.internal.Streams.parse(Streams.java:48) at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:65) at com.google.gson.Gson.fromJson(Gson.java:932) at com.google.gson.Gson.fromJson(Gson.java:1003) at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162) at io.calidog.certstream.CertStreamCertificatePOJODeserializer.deserialize(CertStreamCertificatePOJODeserializer.java:58) at io.calidog.certstream.CertStreamCertificatePOJODeserializer.deserialize(CertStreamCertificatePOJODeserializer.java:8) at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69) at com.google.gson.Gson.fromJson(Gson.java:932) at com.google.gson.Gson.fromJson(Gson.java:1003)

When reaching this line (56)
CertStreamCertificatePOJO retVal = jsonDeserializationContext.deserialize(jsonElement, type);

the deserialize() method is called again, which results in never executing the return retVal line (60) until the StackOverflowError is thrown.

This is from the JsonDeserializationContext doc for the deserialize() method:

Invokes default deserialization on the specified object. It should never be invoked on the element received as a parameter of the deserialize(JsonElement, Type, JsonDeserializationContext) method. Doing so will result in an infinite loop since Gson will in-turn call the custom deserializer again

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

Successfully merging this pull request may close these issues.

IllegalStateException if entry contains "extra" field
2 participants