diff --git a/moshi/src/main/java/com/squareup/moshi/Moshi.java b/moshi/src/main/java/com/squareup/moshi/Moshi.java index 6b98f61..7628370 100644 --- a/moshi/src/main/java/com/squareup/moshi/Moshi.java +++ b/moshi/src/main/java/com/squareup/moshi/Moshi.java @@ -248,7 +248,7 @@ public final class Moshi { } /** - * A possibly-reentrant chain of lookups a JSON adapter. + * A possibly-reentrant chain of lookups for JSON adapters. * *
We keep track of the current stack of lookups: we may start by looking up the JSON adapter * for Employee, re-enter looking for the JSON adapter of HomeAddress, and re-enter again looking diff --git a/moshi/src/test/java/com/squareup/moshi/DeferredAdapterTest.java b/moshi/src/test/java/com/squareup/moshi/DeferredAdapterTest.java index daeea13..4bfae0d 100644 --- a/moshi/src/test/java/com/squareup/moshi/DeferredAdapterTest.java +++ b/moshi/src/test/java/com/squareup/moshi/DeferredAdapterTest.java @@ -35,10 +35,13 @@ public final class DeferredAdapterTest { * the cycle work. It's important that any adapters that depend on this deferred adapter don't * leak out until it's ready. * - *
This test sets up a circular dependency BlueNode to GreenNode to BlueNode and then tries to - * use it before the BlueNode JSON adapter is built, but after the GreenNode adapter is built. It - * creates a similar cycle for BlueNode to RedNode to BlueNode so the order adapters are retrieved - * is insignificant. + *
This test sets up a circular dependency [BlueNode -> GreenNode -> BlueNode] and then tries + * to use a GreenNode JSON adapter before the BlueNode JSON adapter is built. It creates a + * similar cycle [BlueNode -> RedNode -> BlueNode] so the order adapters are retrieved is + * insignificant. + * + *
This used to trigger a crash because we'd incorrectly put the GreenNode JSON adapter in the
+ * cache even though it depended upon an incomplete BlueNode JSON adapter.
*/
@Test public void concurrentSafe() {
final List