Merge changes Iba3a674f,I8ed3f12e,Id6617817 into stable-2.14

* changes:
  InitSshd: Use correct flag to set empty passphrase
  SshSession: Specify charset in constructor of Scanner
  Specify charset in constructors of InputStreamReader
This commit is contained in:
Dave Borowitz
2018-08-31 17:43:28 +00:00
committed by Gerrit Code Review
5 changed files with 10 additions and 6 deletions

View File

@@ -14,6 +14,8 @@
package com.google.gerrit.acceptance;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.base.Preconditions;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -34,7 +36,7 @@ public class HttpResponse {
public Reader getReader() throws IllegalStateException, IOException {
if (reader == null && response.getEntity() != null) {
reader = new InputStreamReader(response.getEntity().getContent());
reader = new InputStreamReader(response.getEntity().getContent(), UTF_8);
}
return reader;
}

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.acceptance;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assert_;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSch;
@@ -52,10 +53,10 @@ public class SshSession {
InputStream err = channel.getErrStream();
channel.connect();
Scanner s = new Scanner(err).useDelimiter("\\A");
Scanner s = new Scanner(err, UTF_8.name()).useDelimiter("\\A");
error = s.hasNext() ? s.next() : null;
s = new Scanner(in).useDelimiter("\\A");
s = new Scanner(in, UTF_8.name()).useDelimiter("\\A");
return s.hasNext() ? s.next() : "";
} finally {
channel.disconnect();

View File

@@ -184,7 +184,7 @@ public class PushCertificateCheckerTest {
}
String cert = payload + new String(bout.toByteArray(), UTF_8);
Reader reader = new InputStreamReader(new ByteArrayInputStream(cert.getBytes(UTF_8)));
Reader reader = new InputStreamReader(new ByteArrayInputStream(cert.getBytes(UTF_8)), UTF_8);
PushCertificateParser parser = new PushCertificateParser(repo, signedPushConfig);
return parser.parse(reader);
}

View File

@@ -104,7 +104,7 @@ class InitSshd implements InitStep {
"-q" /* quiet */,
"-t",
"rsa",
"-P",
"-N",
emptyPassphraseArg,
"-C",
comment,

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.server.mail.send;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assert_;
import static java.nio.charset.StandardCharsets.UTF_8;
import java.io.BufferedReader;
import java.io.InputStream;
@@ -36,7 +37,7 @@ public class ValidatorTest {
if (in == null) {
throw new Exception("TLD list not found");
}
BufferedReader r = new BufferedReader(new InputStreamReader(in));
BufferedReader r = new BufferedReader(new InputStreamReader(in, UTF_8));
String tld;
while ((tld = r.readLine()) != null) {
if (tld.startsWith("# ") || tld.startsWith("XN--")) {