From 978d4dddd54dd0b396b2192a1904c2d48c8ed62d Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Sat, 3 Nov 2018 22:36:17 +1100 Subject: [PATCH] Fix prose in deferred adapters --- moshi/src/main/java/com/squareup/moshi/Moshi.java | 2 +- .../java/com/squareup/moshi/DeferredAdapterTest.java | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) 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 failures = new ArrayList<>();