From d8c313cfa641af351008a4ff80ee6f3fa431ec17 Mon Sep 17 00:00:00 2001 From: Oleg Kuzych Date: Mon, 8 Jun 2020 21:00:17 +0300 Subject: [PATCH] Fix GsonDeserializer to support unicode characters independently of "file.encoding" system property's value being used by JVM (#592) Co-authored-by: Oleh Kuzych --- .../main/java/io/jsonwebtoken/gson/io/GsonDeserializer.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extensions/gson/src/main/java/io/jsonwebtoken/gson/io/GsonDeserializer.java b/extensions/gson/src/main/java/io/jsonwebtoken/gson/io/GsonDeserializer.java index 75ac69b7..f08c37cd 100644 --- a/extensions/gson/src/main/java/io/jsonwebtoken/gson/io/GsonDeserializer.java +++ b/extensions/gson/src/main/java/io/jsonwebtoken/gson/io/GsonDeserializer.java @@ -19,6 +19,8 @@ import com.google.gson.Gson; import io.jsonwebtoken.io.DeserializationException; import io.jsonwebtoken.io.Deserializer; import io.jsonwebtoken.lang.Assert; +import io.jsonwebtoken.lang.Strings; + import java.io.IOException; public class GsonDeserializer implements Deserializer { @@ -54,6 +56,6 @@ public class GsonDeserializer implements Deserializer { } protected T readValue(byte[] bytes) throws IOException { - return gson.fromJson(new String(bytes), returnType); + return gson.fromJson(new String(bytes, Strings.UTF_8), returnType); } }