From 0ef2544275bf9ff250735086dc3cd3e2981bd49c Mon Sep 17 00:00:00 2001 From: Ryan Jiang Date: Thu, 13 Nov 2014 21:46:36 +0800 Subject: [PATCH] Fix corrupted chars while reading from utf-8 stream This issue was found during connecting Jira to Gerrit via Jira Gerrit Plugin. Without charset (utf-8) specified, multi-byte chars could be corrupted thus results in the JSON result returned from Gerrit cannot be parsed at all. --- .../tools/gerrit/gerritevents/ssh/SshConnectionImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/sonymobile/tools/gerrit/gerritevents/ssh/SshConnectionImpl.java b/src/main/java/com/sonymobile/tools/gerrit/gerritevents/ssh/SshConnectionImpl.java index 6cdd229d..d6327d5a 100644 --- a/src/main/java/com/sonymobile/tools/gerrit/gerritevents/ssh/SshConnectionImpl.java +++ b/src/main/java/com/sonymobile/tools/gerrit/gerritevents/ssh/SshConnectionImpl.java @@ -312,7 +312,7 @@ public synchronized Reader executeCommandReader(String command) throws SshExcept try { Channel channel = connectSession.openChannel("exec"); ((ChannelExec)channel).setCommand(command); - InputStreamReader reader = new InputStreamReader(channel.getInputStream()); + InputStreamReader reader = new InputStreamReader(channel.getInputStream(), "utf-8"); channel.connect(); return reader; } catch (JSchException ex) {