JsonReader.peek advances when exception is thrown
Open
bug
- Dominant language
- Java
- Stars
- 24.2k
- Forks
- 4.5k
- Avg merge
- 6d 4h
- Merged PRs (30d)
- 12
Description
When `JsonReader.peek` encounters malformed JSON and throws an exception, it has already modified the state of the reader and advanced one char. This is likely not intended and appears to be the reason why the test `JsonReaderTest.disabled_testNumberWithOctalPrefix` is currently disabled.
Example:
```java
public void testThrowingPeek() throws IOException {
JsonReader reader = new JsonReader(new StringReader("[a?$,1]"));
reader.beginArray();
for (int i = 0; i < 4; i++) {
try {
reader.peek();
} catch (MalformedJsonException expected) {
}
}
reader.nextInt();
reader.endArray();
}
```
Contributor guide
Assessment
This issue has not been assessed yet.