0

I am getting stackoverflow error while deserializing java class.

Code

Gson gson = gsonBuilder.create();
Type listType = new TypeToken<List<StorageEntity>>() {}.getType();
List<StorageEntity> logObj = gson.fromJson (dbDocument, listType);

When I do gson.fromJson (dbDocument, listType), I am getting below mentioned stack trace.

   java.lang.StackOverflowError
        at com.google.gson.SimpleCharStream.GetImage(SimpleCharStream.java)
        at   com.google.gson.JsonParserTokenManager.jjFillToken(JsonParserTokenManager.java)

I have google it and idea that gson is not able to parse long string. Help me to resolve the issue.

Problem is something like this

http://code.google.com/p/google-gson/issues/detail?id=96

but I didn't found any answer.

Sandeep.maurya
  • 401
  • 1
  • 5
  • 6

1 Answers1

1

Check if the object you are trying to deserialize have a circular reference. If yes, there will be an infinite loop.

Guy Bouallet
  • 2,099
  • 11
  • 16