StackOverflowError in delegating TypeAdapterFactory
See original GitHub issueGSON Version: 2.3.1
Description: gson.getDelegateAdapter(this, type)
causes inifinite recursion when used with a @JsonAdapter annotated type.
Minimal example:
package test.gson;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.reflect.TypeToken;
/* @formatter:off */
public class GsonStackOverflowError {
public static void main(final String[] args) {
new Gson().fromJson("{}", A.class);
}
@JsonAdapter(Adapter.class)
public static class A {}
public static class Adapter implements TypeAdapterFactory {
@Override
public <T> TypeAdapter<T> create(final Gson gson, final TypeToken<T> type)
{
gson.getDelegateAdapter(this, type);
throw new IllegalStateException("Not reproducible");
}
}
}
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to invoke default deserialize with gson - Stack Overflow
Try using GSON >= 2.2.1 and look for the TypeAdapterFactory class. ... override fun write(out: JsonWriter, value: T?) { delegate.write(out, ...
Read more >StackOverflowError occurs when running tasks query ... - IBM
StackOverflowError occurs when running tasks query from the REST API Tester tool ... StackOverflowError at com.lombardisoftware.client.delegate.
Read more >How to Fix java.lang.StackOverflowError in Java - Rollbar
StackOverflowError indicates that the application stack is exhausted and is usually caused by deep or infinite recursion. What Causes java.lang.
Read more >StackOverflowError when using a FlowableEventListener and ...
flowable.engine.delegate.event.impl.FlowableEventSupport.dispatchEvent(FlowableEventSupport.java:107) at org.flowable.engine.delegate.event.impl ...
Read more >StackOverflowError (Java Platform SE 8 ) - Oracle Help Center
public class StackOverflowError extends VirtualMachineError. Thrown when a stack overflow occurs because an application recurses too deeply.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for following up
I can confirm that the issue is resolved as of Gson 2.7. Should this issue be closed?