diff --git a/gson/GSON 2.0 NOTES.txt b/gson/GSON 2.0 NOTES.txt index 45dbc71c..9fa8c930 100644 --- a/gson/GSON 2.0 NOTES.txt +++ b/gson/GSON 2.0 NOTES.txt @@ -38,3 +38,11 @@ GSON 1.x supports type adapters for primitive types GSON 2.x doesn't com.google.gson.functional.CustomTypeAdaptersTest.testCustomSerializerForLong com.google.gson.functional.CustomTypeAdaptersTest.testCustomDeserializerForLong + + +GSON 1.x throws IllegalStateException on circular references +GSON 2.x lets the runtime throw a StackOverflowError +com.google.gson.functional.CircularReferenceTest.testCircularSerialization +com.google.gson.functional.CircularReferenceTest.testSelfReferenceSerialization +com.google.gson.functional.CircularReferenceTest.testSelfReferenceArrayFieldSerialization +com.google.gson.functional.CircularReferenceTest.testSelfReferenceCustomHandlerSerialization \ No newline at end of file diff --git a/gson/src/test/java/com/google/gson/functional/CircularReferenceTest.java b/gson/src/test/java/com/google/gson/functional/CircularReferenceTest.java index f1367eb4..202e7863 100644 --- a/gson/src/test/java/com/google/gson/functional/CircularReferenceTest.java +++ b/gson/src/test/java/com/google/gson/functional/CircularReferenceTest.java @@ -52,8 +52,7 @@ public class CircularReferenceTest extends TestCase { try { gson.toJson(a); fail("Circular types should not get printed!"); - } catch (IllegalStateException expected) { - assertTrue(expected.getMessage().contains("children")); + } catch (StackOverflowError expected) { } } @@ -64,7 +63,8 @@ public class CircularReferenceTest extends TestCase { try { gson.toJson(objA); fail("Circular reference to self can not be serialized!"); - } catch (IllegalStateException expected) { } + } catch (StackOverflowError expected) { + } } public void testSelfReferenceArrayFieldSerialization() throws Exception { @@ -74,8 +74,7 @@ public class CircularReferenceTest extends TestCase { try { gson.toJson(objA); fail("Circular reference to self can not be serialized!"); - } catch (IllegalStateException expected) { - assertTrue(expected.getMessage().contains("children")); + } catch (StackOverflowError expected) { } } @@ -94,8 +93,7 @@ public class CircularReferenceTest extends TestCase { try { gson.toJson(obj); fail("Circular reference to self can not be serialized!"); - } catch (IllegalStateException expected) { - assertTrue(expected.getMessage().contains("Offending")); + } catch (StackOverflowError expected) { } }