Specify charset in constructors of InputStreamReader

ErrorProne reports a warning [1] about implicit use of the platform
default charset.

[1] http://errorprone.info/bugpattern/DefaultCharset

Change-Id: Id661781773ca175b52a17cf4d80c37fad17344a8
This commit is contained in:
David Pursehouse 2018-08-31 10:15:26 +09:00
parent 9932a88865
commit ce98c50f38
3 changed files with 6 additions and 3 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

@ -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

@ -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--")) {