* Fix #2334

This commit replaces the `NumberFormatException` with `MalformedJsonException` in the `JsonReader#readEscapeCharacter()` and also fixes the tests.

* Removes white-space
This commit is contained in:
Maicol 2023-03-06 17:24:09 +01:00 committed by GitHub
parent 0adcdc80d5
commit 85ebaf7c35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -1587,7 +1587,7 @@ public class JsonReader implements Closeable {
* been read. This supports both unicode escapes "u000A" and two-character * been read. This supports both unicode escapes "u000A" and two-character
* escapes "\n". * escapes "\n".
* *
* @throws NumberFormatException if any unicode escape sequences are * @throws MalformedJsonException if any unicode escape sequences are
* malformed. * malformed.
*/ */
@SuppressWarnings("fallthrough") @SuppressWarnings("fallthrough")
@ -1614,7 +1614,7 @@ public class JsonReader implements Closeable {
} else if (c >= 'A' && c <= 'F') { } else if (c >= 'A' && c <= 'F') {
result += (c - 'A' + 10); result += (c - 'A' + 10);
} else { } else {
throw new NumberFormatException("\\u" + new String(buffer, pos, 4)); throw new MalformedJsonException("\\u" + new String(buffer, pos, 4));
} }
} }
pos += 4; pos += 4;

View File

@ -355,7 +355,7 @@ public final class JsonReaderTest {
try { try {
reader.nextString(); reader.nextString();
fail(); fail();
} catch (NumberFormatException expected) { } catch (MalformedJsonException expected) {
} }
} }