[Question] StackOverflowError: com.google.gson.internal loop error
See original GitHub issueHi, im testing the playwright-java maven plugin, the version 0.180.0, with JDK 1.8 and maven project in java 1.8. I have a loop error trying the example test PageScreenshot
This is the loop error:
Exception in thread "main" java.lang.StackOverflowError
at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:378)
at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:383)
// + 750 times loop code
at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:358)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:158)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:100)
at com.google.gson.Gson.getAdapter(Gson.java:423)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:115)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:164)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:100)
at com.google.gson.Gson.getAdapter(Gson.java:423)
// + 250 times loop code
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:115)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:164)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:100)
at com.google.gson.Gson.getAdapter(Gson.java:423)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:115)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:164)
How can I solve this? Thanks everyone for your help
Issue Analytics
- State:
- Created 3 years ago
- Comments:28 (10 by maintainers)
Top Results From Across the Web
gson.toJson() throws StackOverflowError - Stack Overflow
I encountered this issue when passing service object reference as context. Fix was to make the context variable static in the class that...
Read more >Issue 440 in google-gson: Infinity loop at recursive calling com ...
New issue 440 by metricst...@gmail.com: Infinity loop at recursive calling com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
Read more >The StackOverflowError in Java - Baeldung
This stack trace shows the line numbers that cause the problem in the two classes that are in a cyclic relationship. Line number...
Read more >How to Fix java.lang.StackOverflowError in Java - Rollbar
The java.lang.StackOverflowError is a runtime error which points to serious problems that cannot be caught by an application. The java.lang.
Read more >StackOverflowError in Java with examples - GeeksforGeeks
StackOverflowError is an error which Java doesn't allow to catch, for instance, stack running out of space, as it's one of the most...
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 Free
Top 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
Solved! I had a similar problem with another library and here I explain the problem in detail. https://github.com/MrGraversen/rust-rcon/pull/2
The error in short, is that Gson from JDK 12 fails, even if you compile in a previous java. The solution is to go to the latest version of Gson

Edit: Reviewing I have seen that you have the latest version of playwright. Probably then, that you are trying to use an older version and not the latest one.
Edit 2: Ok, in the latest version you don’t define the gson version, project can try to use another version. In the new one, you do define it to the latest version.
Thanks for the thorough investigation!
The version is specified the dependency management section of this pom.xml which is specified as parent project for playwright. As far as I understand this should enforce the version for all submodules but it looks like it does not happen in your case.
I’m closing this for now, but please feel free to reopen if you believe we can fix it on playwright end.