diff --git a/java/src/org/openqa/selenium/json/JsonInput.java b/java/src/org/openqa/selenium/json/JsonInput.java index 5c8842851a3e0..c116a24b3d9c6 100644 --- a/java/src/org/openqa/selenium/json/JsonInput.java +++ b/java/src/org/openqa/selenium/json/JsonInput.java @@ -39,8 +39,7 @@ public class JsonInput implements Closeable { private final Reader source; - // FIXME: This flag is never set - private final boolean readPerformed = false; + private boolean readPerformed = false; private JsonTypeCoercer coercer; private PropertySetting setter; private final Input input; @@ -49,6 +48,7 @@ public class JsonInput implements Closeable { private final Deque stack = new ArrayDeque<>(); JsonInput(Reader source, JsonTypeCoercer coercer, PropertySetting setter) { + this.source = Require.nonNull("Source", source); this.coercer = Require.nonNull("Coercer", coercer); this.input = new Input(source); @@ -402,6 +402,10 @@ public void skipValue() { } } + private void markReadPerformed() { + readPerformed = true; + } + /** * Read the next element from the JSON input stream as the specified type. * @@ -413,6 +417,7 @@ public void skipValue() { * @throws UncheckedIOException if an I/O exception is encountered */ public T read(Type type) { + markReadPerformed(); skipWhitespace(input); // Guard against reading an empty stream