Fix prose in deferred adapters

This commit is contained in:
Jesse Wilson
2018-11-03 22:36:17 +11:00
parent 0cb2aef646
commit 978d4dddd5
2 changed files with 8 additions and 5 deletions

View File

@@ -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.
* *
* <p>We keep track of the current stack of lookups: we may start by looking up the JSON adapter * <p>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 * for Employee, re-enter looking for the JSON adapter of HomeAddress, and re-enter again looking

View File

@@ -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 * the cycle work. It's important that any adapters that depend on this deferred adapter don't
* leak out until it's ready. * leak out until it's ready.
* *
* <p>This test sets up a circular dependency BlueNode to GreenNode to BlueNode and then tries to * <p>This test sets up a circular dependency [BlueNode -> GreenNode -> BlueNode] and then tries
* use it before the BlueNode JSON adapter is built, but after the GreenNode adapter is built. It * to use a GreenNode JSON adapter before the BlueNode JSON adapter is built. It creates a
* creates a similar cycle for BlueNode to RedNode to BlueNode so the order adapters are retrieved * similar cycle [BlueNode -> RedNode -> BlueNode] so the order adapters are retrieved is
* is insignificant. * insignificant.
*
* <p>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() { @Test public void concurrentSafe() {
final List<Throwable> failures = new ArrayList<>(); final List<Throwable> failures = new ArrayList<>();