### Question:
JsonAdapter { @CheckReturnValue public final JsonAdapter<T> failOnUnknown() { final JsonAdapter<T> delegate = this; return new JsonAdapter<T>() { @Override public @Nullable T fromJson(JsonReader reader) throws IOException { boolean skipForbidden = reader.failOnUnknown(); reader.setFailOnUnknown(true); try { return delegate.fromJson(reader); } finally { reader.setFailOnUnknown(skipForbidden); } } @Override public void toJson(JsonWriter writer, @Nullable T value) throws IOException { delegate.toJson(writer, value); } @Override boolean isLenient() { return delegate.isLenient(); } @Override public String toString() { return delegate + ".failOnUnknown()"; } }; }  @CheckReturnValue abstract @Nullable T fromJson(JsonReader reader); @CheckReturnValue final @Nullable T fromJson(BufferedSource source); @CheckReturnValue final @Nullable T fromJson(String string); abstract void toJson(JsonWriter writer, @Nullable T value); final void toJson(BufferedSink sink, @Nullable T value); @CheckReturnValue final String toJson(@Nullable T value); @CheckReturnValue final @Nullable Object toJsonValue(@Nullable T value); @CheckReturnValue final @Nullable T fromJsonValue(@Nullable Object value); @CheckReturnValue final JsonAdapter<T> serializeNulls(); @CheckReturnValue final JsonAdapter<T> nullSafe(); @CheckReturnValue final JsonAdapter<T> nonNull(); @CheckReturnValue final JsonAdapter<T> lenient(); @CheckReturnValue final JsonAdapter<T> failOnUnknown(); @CheckReturnValue JsonAdapter<T> indent(final String indent);  }### Answer:
@Test public void failOnUnknown() throws Exception { JsonAdapter<String> alwaysSkip = new JsonAdapter<String>() { @Override public String fromJson(JsonReader reader) throws IOException { reader.skipValue(); throw new AssertionError(); } @Override public void toJson(JsonWriter writer, String value) throws IOException { throw new AssertionError(); } }.failOnUnknown(); JsonReader reader = factory.newReader("[\"a\"]"); reader.beginArray(); try { alwaysSkip.fromJson(reader); fail(); } catch (JsonDataException expected) { assertThat(expected).hasMessageThat().isEqualTo("Cannot skip unexpected STRING at $[0]"); } assertThat(reader.nextString()).isEqualTo("a"); reader.endArray(); }