Open GoogleCodeExporter opened 9 years ago
I got this issue too, but it worked fine until I upgraded to the latest JDK
1.7u4, so I guess it will soon be a problem for many developers.
Original comment by enrique....@gmail.com
on 4 May 2012 at 9:54
I got it with u3. Interesting if the problem is really GSON or JDK.
Original comment by metricst...@gmail.com
on 4 May 2012 at 8:04
Very interesting. Could you share what type you were serializing? I'd love to
get to the bottom of this.
Original comment by limpbizkit
on 30 Jun 2012 at 3:20
I too got the same exception when loading the java objects from json file. I
have registered JsonDeserializer adapter for polymorphic classes.
I could not start the application as the startup servlet need to parse and load
the configured objects in the json file.
error stack attached
Original comment by vijay.ra...@gmail.com
on 23 Jul 2012 at 1:08
Attachments:
There isn't much I can do about this until we know which type was being
serialized.
Original comment by limpbizkit
on 2 Sep 2012 at 9:41
[deleted comment]
class TestClass { Thread t; }
Although no json interpretation could be expected, a more graceful error would
be nice.
Original comment by myem...@email123.com
on 10 Sep 2012 at 2:09
This bug reproduces with this test:
static class ToResolve<T> {
List<T> list;
public void testResolve() throws Exception {
System.out.println($Gson$Types.resolve(new TypeToken<ToResolve<? extends T>>() {}.getType(), ToResolve.class,
ToResolve.class.getDeclaredField("list").getGenericType()));
}
}
public void testResolve() throws Exception {
new ToResolve<Void>().testResolve();
}
It will also reproduce with Guice by using a TypeLiteral instead of a TypeToken.
System.out.println(new TypeLiteral<ToResolve<? extends T>>() {}
.resolve(ToResolve.class.getDeclaredField("list").getGenericType()));
Original comment by limpbizkit
on 25 Sep 2012 at 3:06
I've been staring at this for a while and I'm starting to think it's a
programming error. When this situation comes up, the runtime types are a hall
of mirrors!
Outermost we have our declaring class: ToResolve<T>.
It creates a ToResolve<? extends T>, so its T is defined as ? extends T.
That wildcard is resolved to <? extends ? extends ? extends ? extends ... T>,
never reaching a definite type.
We could try to naively defend against this, but we'd still be broken for many
cases. There's an arbitrary number of ways to make a type recurse onto itself.
ToResolve<? super List<T>>
We could keep an explicit stack, and if we ever attempt to resolve a type
that's already on the stack, we've entered an illegal recursion and could
terminate immediately without resolution. This is unsatisfying but it would
work.
I think the right solution is for impacted apps to rethink their models. Why
are they serializing types that are not well-defined? Why are they serializing
'Thread' objects without a type adapter? Is this just capturing a lot of
information for debugging? That's a bad idea, particularly since circular
references are also possible.
I'm willing to hear genuine use cases here, but I think the solution is going
to be to forbid this case and leave the stack overflow as-is.
Original comment by limpbizkit
on 25 Sep 2012 at 3:23
The problem I encountered was :
* same stack trace
* able to reproduce, again and again.
* able to debug,
* origin of troubles : the serializer wasn't registered for the real type of the object (using registerTypeAdapter) but for a mother class of it (found it through debug).
* explaination of what happened in my case : the Gson object found by itself acceptable adapter for the real object, but stumbled upon deep hidden object java.lang.ref.ReferenceQueue which had a member pointing to the object itself, hence the stackoverflow, as the serializer looped over it.
* correction : added a-bit-crappy command :
gsonBuilder.registerTypeAdapter(objectToSerialize.getClass(), // to get its real type
objectToSerializeSerializer);
(as the real type class of the object to serialize is private).
Original comment by glouglou...@gmail.com
on 12 Dec 2012 at 4:58
I have same problem when using API 17.
On smaller API versions it's all OK.
Why on API 17 - i got StackOverflow error?
Original comment by nelepo...@gmail.com
on 18 Jan 2013 at 8:29
I believe it was in API 17 that the internals of WeakReference and
SoftReference changed to be self-referent, which would trigger this. Are you
using Gson to serialize a WeakReference or SoftReference? If you are, you
should write your own TypeAdapter for those types.
Original comment by limpbizkit
on 18 Jan 2013 at 2:54
I am seeing this issue as well, and only on API 17. API 16 and lower work
fine.
01-18 13:32:10.146: E/AndroidRuntime(831): FATAL EXCEPTION: main
01-18 13:32:10.146: E/AndroidRuntime(831): java.lang.StackOverflowError
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:355)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(Reflec
tiveTypeAdapterFactory.java:117)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveType
AdapterFactory.java:72)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.Gson.getAdapter(Gson.java:353)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTy
peAdapterFactory.java:82)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(Refl
ectiveTypeAdapterFactory.java:81)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(Reflec
tiveTypeAdapterFactory.java:118)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveType
AdapterFactory.java:72)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.Gson.getAdapter(Gson.java:353)
01-18 13:32:10.146: E/AndroidRuntime(831): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTy
peAdapterFactory.jav
Original comment by androidd...@gmail.com
on 18 Jan 2013 at 6:41
Issue 496 has been merged into this issue.
Original comment by limpbizkit
on 4 Feb 2013 at 4:03
Here is my case, I have this JSON response that I want to convert to a java
object, with GSON v1.7.1 it works just fine, while with 2.2.2 it fails with the
StackOverflow error on Android API 17, what am I doing wrong?
Original comment by rkat...@gmail.com
on 5 Feb 2013 at 10:57
Attachments:
The problem is classes like SoftReference and WeakReference. Are you
serializing either of those? (Because those classes have self-referential
generics.)
Original comment by limpbizkit
on 5 Feb 2013 at 11:04
No, I don't have the classes serialized, and there are no self referential, the
main class has 2 sub types, which are just simple pojo 1 level String or int
types..
Original comment by rkat...@gmail.com
on 6 Feb 2013 at 7:07
No SoftReference or WeakReferences in our code either. Very basic classes that
work on Android 4.1.2 and don't on 4.2.x. Not a Java expert and am unclear on
how, if this is an internals issue, gson v1.71 resolves the issue? Thanks.
Original comment by d...@aylanetworks.com
on 6 Feb 2013 at 7:43
Dan: it's a problem with types that circularly reference themselves. It's most
notable in WeakReference & SoftReference, which started to circularly reference
themselves starting with Android API 17.
I'm reopening this because the app developer can't do much to defend himself
against this, and it's an ugly crash.
Original comment by limpbizkit
on 6 Feb 2013 at 2:31
I am having the same issue for API 15 as well. Worked fine on API 8.
I tried using Gson 1.7 with API 15
but I got the error as shown in the attached log file
Original comment by sourabh....@gmail.com
on 28 Feb 2013 at 2:43
Attachments:
In .NET, you are not allowed to serialize/deserialize complexe objects that
might recur into itself. Runtime exception is thrown when
serialization/deserialization of such objects are attempted.
IMO, you should disallow this use case. Or specify a max recursion level to
serialize/deserialize into.
Original comment by IsenGrim...@gmail.com
on 18 Apr 2013 at 8:35
This turn out to be the declaration of android.os.Handler in the
deserialization class.
Original comment by d...@aylanetworks.com
on 19 Apr 2013 at 4:59
In case this help narrow the problem, I solved the problem by following Zar
answer on http://stackoverflow.com/a/14572063/279565.
I had added at some point a member
private LogCentral log = LogCentral.getInstance();
LogCentral being a singleton, (not related to Log4j or smilar). Just a plain
simple filewriter class.
Making the member static solves the problem, although I don't know why.
Original comment by Alain.Vi...@gmail.com
on 1 May 2013 at 7:27
this bug is reproducable with this simple class
public class Prepare {
private ScheduledThreadPoolExecutor downloadJobExecutorPool;
public static void main(String... arguments) throws Exception {
Prepare stService = new Prepare();
System.out.println(stService.toJson());
}
public String toJson(){
Gson gson = new Gson();
return gson.toJson(this);
}
}
have a ScheduledThreadPoolExecutor in your class and this bug happens in 2.2.2
and 2.2.4 but not in 1.7.1
Original comment by kereno...@gmail.com
on 9 Sep 2013 at 10:19
I reproduced this error in the following use case: I have a series of objects
that use a generic fluent pattern, i.e.
public MyAbstractClass<M extends MyAbstractClass> {
private int value;
public M setValue(int value) {
this.value = value;
return (M) this;
}
}
public MyImpl extends MyAbstractClass<MyImpl> {
private int foo;
public MyImpl setSomethingElse(int foo) {
this.foo = foo;
}
}
public static void main(String... args) {
MyImpl impl = new MyImpl();
myImpl.setValue(1)
.setSomethingElse(foo);
}
I'm not really griping that this error happens so much as:
1) It's difficult to diagnose exactly where the problem is
2) The object that I was serializing had a registered type adapter for it's
INTERFACE, like:
public MyOuterClass implements SomeInterface {
private MyImpl impl;
// etc.
}
then:
gsonBuilder.registerTypeAdapter(SomeInterface.class, someInterfaceTypeAdapter);
Where someInterfaceTypeAdapter doesn't call anything on the MyImpl argument.
What I'm saying is, it shouldn't have this hangup when there's a type adapter
that's supposed to handle the job. I fixed the problem by doing:
gsonBuilder.registerTypeAdapter(MyOuterClass.class, someInterfaceTypeAdapter);
Gson should be smart enough to realize it doesn't have to go through the
trouble of reading all the fields if there is an appropriate type adapter.
Original comment by martin.j...@gmail.com
on 3 Oct 2013 at 11:30
11-03 00:57:31.998: E/AndroidRuntime(7980): FATAL EXCEPTION: main
11-03 00:57:31.998: E/AndroidRuntime(7980): java.lang.StackOverflowError
11-03 00:57:31.998: E/AndroidRuntime(7980): at
java.lang.String._getChars(String.java:903)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:147)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
java.lang.StringBuffer.append(StringBuffer.java:219)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
java.io.StringWriter.write(StringWriter.java:147)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
java.io.StringWriter.append(StringWriter.java:199)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
java.io.StringWriter.append(StringWriter.java:30)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.stream.JsonWriter.beforeValue(JsonWriter.java:626)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.stream.JsonWriter.open(JsonWriter.java:325)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.stream.JsonWriter.beginObject(JsonWriter.java:308)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(Reflect
iveTypeAdapterFactory.java:190)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRun
timeTypeWrapper.java:68)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTyp
eAdapterFactory.java:89)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(Reflect
iveTypeAdapterFactory.java:195)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRun
timeTypeWrapper.java:68)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTyp
eAdapterFactory.java:89)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(Reflect
iveTypeAdapterFactory.java:195)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRun
timeTypeWrapper.java:68)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTyp
eAdapterFactory.java:89)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(Reflect
iveTypeAdapterFactory.java:195)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRun
timeTypeWrapper.java:68)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTyp
eAdapterFactory.java:89)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(Reflect
iveTypeAdapterFactory.java:195)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRun
timeTypeWrapper.java:68)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTyp
eAdapterFactory.java:89)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(Reflect
iveTypeAdapterFactory.java:195)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRun
timeTypeWrapper.java:68)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTyp
eAdapterFactory.java:89)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(Reflect
iveTypeAdapterFactory.java:195)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRun
timeTypeWrapper.java:68)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTyp
eAdapterFactory.java:89)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(Reflect
iveTypeAdapterFactory.java:195)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRun
timeTypeWrapper.java:68)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTyp
eAdapterFactory.java:89)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(Reflect
iveTypeAdapterFactory.java:195)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRun
timeTypeWrapper.java:68)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTyp
eAdapterFactory.java:89)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(Reflect
iveTypeAdapterFactory.java:195)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRun
timeTypeWrapper.java:68)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTyp
eAdapterFactory.java:89)
11-03 00:57:31.998: E/AndroidRuntime(7980): at
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(Reflect
iveTypeAdapterFactory.java:195)
11-03 00:57:31.998: E/AndroidRuntime(7980): a
Same here.
Original comment by MichaelA...@gmail.com
on 2 Nov 2013 at 11:01
on Version 2.2.3
I have same issue cause my model implements Comparable of its type:
class X implements Comparable<X>{
// members ...
// @NOTE: this has a problem when down grading to 1.7.1
Map<String, Object> parameters;
}
when I downgraded to version 1.7.1 the parameters map is not deserialized
correctly if I received a String for the value, this will save the key
correctly but the String value is saved as object and when trying to cast it
back to string It will throw an exception.
Original comment by ahmad.m...@exalt.ps
on 4 Nov 2013 at 8:03
I had the same problem. Turned out that my model classes parent class had a
field that was not marked as transient but definitely should have been. This
was not an issue with Android 4.0.4 but it is under 4.3.
Original comment by andre.w...@gmail.com
on 26 Nov 2013 at 3:37
Issue 554 has been merged into this issue.
Original comment by inder123
on 29 Mar 2014 at 10:39
Same issue here with Objects containing WeakReferences. Because I didn't need
that particular ivar to be serialized, I circumvented this problem by applying
the transient flag.
Original comment by mat...@weheartit.com
on 7 Apr 2014 at 12:13
I lowered gson to 1.7.2 as noted on:
http://stackoverflow.com/questions/14565647/gson-2-2-2-causing-a-stackoverflow-o
n-4-2-1-only
And that solved the problem for my project.
Original comment by jeremyvillalobos
on 13 May 2014 at 5:56
I solved this problem like this http://stackoverflow.com/a/24319892/1411598
Original comment by strukac...@gmail.com
on 20 Jun 2014 at 4:26
confirm on gson 2.2.4 (android api 17-19) with WeakReference. Making field
"transient" solves problem (or you can try @Expose)
Original comment by MMaximil...@gmail.com
on 2 Jul 2014 at 9:18
I solve this problem realizing interface Serializable. Each class has to be
realized this interface
Original comment by ailton.mizuki
on 13 Aug 2014 at 8:12
I too had this problem and I solved it ..by realizing I was trying to serialize
the wrong class - my service class ("this") instead of my model class. ^_^'
(But I think it was the logger blocking serialization of my service class - see
http://stackoverflow.com/a/14572063/2693875)
Original comment by gdubi...@bidlab.pl
on 29 Aug 2014 at 2:38
Original issue reported on code.google.com by
metricst...@gmail.com
on 29 Apr 2012 at 5:31