From 0495cdb6d76df73c9153112b1c9c8f15d656920a Mon Sep 17 00:00:00 2001 From: Shershah03 Date: Mon, 24 Mar 2025 00:15:48 +0530 Subject: [PATCH 1/2] [Issue-2816] - Update exception type in Gson#fromJson to JsonParseException --- gson/src/main/java/com/google/gson/Gson.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gson/src/main/java/com/google/gson/Gson.java b/gson/src/main/java/com/google/gson/Gson.java index c2d7b618c1..af89c2edb6 100644 --- a/gson/src/main/java/com/google/gson/Gson.java +++ b/gson/src/main/java/com/google/gson/Gson.java @@ -1098,12 +1098,12 @@ public JsonReader newJsonReader(Reader reader) { * @param classOfT the class of T * @return an object of type T from the string. Returns {@code null} if {@code json} is {@code * null} or if {@code json} is empty. - * @throws JsonSyntaxException if json is not a valid representation for an object of type + * @throws JsonParseException if json is not a valid representation for an object of type * classOfT * @see #fromJson(Reader, Class) * @see #fromJson(String, TypeToken) */ - public T fromJson(String json, Class classOfT) throws JsonSyntaxException { + public T fromJson(String json, Class classOfT) throws JsonParseException { return fromJson(json, TypeToken.get(classOfT)); } From 01b5ea8b8a891bca38747c3588d341cf57270a3f Mon Sep 17 00:00:00 2001 From: Shershah03 Date: Mon, 24 Mar 2025 00:30:48 +0530 Subject: [PATCH 2/2] Update exception type in Gson#fromJson to JsonParseException --- gson/src/main/java/com/google/gson/Gson.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gson/src/main/java/com/google/gson/Gson.java b/gson/src/main/java/com/google/gson/Gson.java index af89c2edb6..c4a4a7bb4e 100644 --- a/gson/src/main/java/com/google/gson/Gson.java +++ b/gson/src/main/java/com/google/gson/Gson.java @@ -1098,8 +1098,7 @@ public JsonReader newJsonReader(Reader reader) { * @param classOfT the class of T * @return an object of type T from the string. Returns {@code null} if {@code json} is {@code * null} or if {@code json} is empty. - * @throws JsonParseException if json is not a valid representation for an object of type - * classOfT + * @throws JsonParseException if json is not a valid representation for an object of type classOfT * @see #fromJson(Reader, Class) * @see #fromJson(String, TypeToken) */