question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

StackOverflowError in delegating TypeAdapterFactory

See original GitHub issue

GSON 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:closed
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
JakeWhartoncommented, Aug 25, 2016

Thanks for following up

1reaction
kevinmostcommented, Aug 25, 2016

I can confirm that the issue is resolved as of Gson 2.7. Should this issue be closed?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found