From 690c812f19e7af5e5f96c68c78d3f02101f64dab Mon Sep 17 00:00:00 2001 From: Oleh Kuzych Date: Fri, 15 May 2020 18:20:42 +0300 Subject: [PATCH] Fix GsonDeserializer to support unicode characters independently of "file.encoding" system property's value being used by JVM --- .../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 75ac69b77..f08c37cd3 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 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 T deserialize(byte[] bytes) throws DeserializationException { } protected T readValue(byte[] bytes) throws IOException { - return gson.fromJson(new String(bytes), returnType); + return gson.fromJson(new String(bytes, Strings.UTF_8), returnType); } }