Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
fix(Fetch): invalid encoding if deserializing with non-UTF-8 JVM
Browse files Browse the repository at this point in the history
Closes #49
  • Loading branch information
mkalen committed Oct 29, 2018
1 parent 1626565 commit cf7823f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion nodes/src/main/java/io/aexp/nodes/graphql/Fetch.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -64,7 +65,9 @@ <T> GraphQLResponseEntity<T> send(GraphQLRequestEntity requestEntity, Class<T> r
} catch(IOException exception) {
inputStream = connection.getErrorStream();
}
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
// Force stream reader to use UTF-8 for parsing, in order for deserialization not to use invalid
// encoding when reading from the underlying stream during JSON parsing
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));

Wrapper<T> wrapper = deserializeResponse(bufferedReader, responseClass);

Expand Down

0 comments on commit cf7823f

Please sign in to comment.