Import StandardCharsets.UTF_8 as static
Change-Id: I066770f2eddfa7e9c1a67e91544006d33062d6d0
This commit is contained in:
parent
7f6601429a
commit
c5cc9ddd12
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.acceptance;
|
package com.google.gerrit.acceptance;
|
||||||
|
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.gerrit.server.config.SitePaths;
|
import com.google.gerrit.server.config.SitePaths;
|
||||||
@ -27,7 +29,6 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.ProcessBuilder.Redirect;
|
import java.lang.ProcessBuilder.Redirect;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
@ -134,7 +135,7 @@ public abstract class PluginDaemonTest extends AbstractDaemonTest {
|
|||||||
Path buckFile = pluginSource.resolve("BUCK");
|
Path buckFile = pluginSource.resolve("BUCK");
|
||||||
byte[] bytes = Files.readAllBytes(buckFile);
|
byte[] bytes = Files.readAllBytes(buckFile);
|
||||||
String buckContent =
|
String buckContent =
|
||||||
new String(bytes, StandardCharsets.UTF_8).replaceAll("\\s+", "");
|
new String(bytes, UTF_8).replaceAll("\\s+", "");
|
||||||
Matcher matcher =
|
Matcher matcher =
|
||||||
Pattern.compile("gerrit_plugin\\(name='(.*?)'").matcher(buckContent);
|
Pattern.compile("gerrit_plugin\\(name='(.*?)'").matcher(buckContent);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
package com.google.gerrit.acceptance;
|
package com.google.gerrit.acceptance;
|
||||||
|
|
||||||
import static com.google.gerrit.httpd.restapi.RestApiServlet.JSON_MAGIC;
|
import static com.google.gerrit.httpd.restapi.RestApiServlet.JSON_MAGIC;
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
public class RestResponse extends HttpResponse {
|
public class RestResponse extends HttpResponse {
|
||||||
|
|
||||||
@ -30,9 +30,8 @@ public class RestResponse extends HttpResponse {
|
|||||||
@Override
|
@Override
|
||||||
public Reader getReader() throws IllegalStateException, IOException {
|
public Reader getReader() throws IllegalStateException, IOException {
|
||||||
if (reader == null && response.getEntity() != null) {
|
if (reader == null && response.getEntity() != null) {
|
||||||
reader =
|
reader = new InputStreamReader(
|
||||||
new InputStreamReader(response.getEntity().getContent(),
|
response.getEntity().getContent(), UTF_8);
|
||||||
StandardCharsets.UTF_8);
|
|
||||||
reader.skip(JSON_MAGIC.length);
|
reader.skip(JSON_MAGIC.length);
|
||||||
}
|
}
|
||||||
return reader;
|
return reader;
|
||||||
|
@ -19,6 +19,7 @@ import static com.google.gerrit.acceptance.PushOneCommit.FILE_CONTENT;
|
|||||||
import static com.google.gerrit.acceptance.PushOneCommit.FILE_NAME;
|
import static com.google.gerrit.acceptance.PushOneCommit.FILE_NAME;
|
||||||
import static com.google.gerrit.acceptance.PushOneCommit.PATCH;
|
import static com.google.gerrit.acceptance.PushOneCommit.PATCH;
|
||||||
import static org.eclipse.jgit.lib.Constants.HEAD;
|
import static org.eclipse.jgit.lib.Constants.HEAD;
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
@ -53,7 +54,6 @@ import org.junit.Before;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -429,7 +429,7 @@ public class RevisionIT extends AbstractDaemonTest {
|
|||||||
.content();
|
.content();
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
bin.writeTo(os);
|
bin.writeTo(os);
|
||||||
String res = new String(os.toByteArray(), StandardCharsets.UTF_8);
|
String res = new String(os.toByteArray(), UTF_8);
|
||||||
assertThat(res).isEqualTo(FILE_CONTENT);
|
assertThat(res).isEqualTo(FILE_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -555,7 +555,7 @@ public class RevisionIT extends AbstractDaemonTest {
|
|||||||
.patch();
|
.patch();
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
bin.writeTo(os);
|
bin.writeTo(os);
|
||||||
String res = new String(os.toByteArray(), StandardCharsets.UTF_8);
|
String res = new String(os.toByteArray(), UTF_8);
|
||||||
ChangeInfo change = changeApi.get();
|
ChangeInfo change = changeApi.get();
|
||||||
RevisionInfo rev = change.revisions.get(change.currentRevision);
|
RevisionInfo rev = change.revisions.get(change.currentRevision);
|
||||||
DateFormat df = new SimpleDateFormat(
|
DateFormat df = new SimpleDateFormat(
|
||||||
|
@ -77,7 +77,6 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -749,21 +748,21 @@ public class ChangeEditIT extends AbstractDaemonTest {
|
|||||||
private String newChange(PersonIdent ident) throws Exception {
|
private String newChange(PersonIdent ident) throws Exception {
|
||||||
PushOneCommit push =
|
PushOneCommit push =
|
||||||
pushFactory.create(db, ident, testRepo, PushOneCommit.SUBJECT, FILE_NAME,
|
pushFactory.create(db, ident, testRepo, PushOneCommit.SUBJECT, FILE_NAME,
|
||||||
new String(CONTENT_OLD, StandardCharsets.UTF_8));
|
new String(CONTENT_OLD, UTF_8));
|
||||||
return push.to("refs/for/master").getChangeId();
|
return push.to("refs/for/master").getChangeId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String amendChange(PersonIdent ident, String changeId) throws Exception {
|
private String amendChange(PersonIdent ident, String changeId) throws Exception {
|
||||||
PushOneCommit push =
|
PushOneCommit push =
|
||||||
pushFactory.create(db, ident, testRepo, PushOneCommit.SUBJECT, FILE_NAME2,
|
pushFactory.create(db, ident, testRepo, PushOneCommit.SUBJECT, FILE_NAME2,
|
||||||
new String(CONTENT_NEW2, StandardCharsets.UTF_8), changeId);
|
new String(CONTENT_NEW2, UTF_8), changeId);
|
||||||
return push.to("refs/for/master").getChangeId();
|
return push.to("refs/for/master").getChangeId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String newChange2(PersonIdent ident) throws Exception {
|
private String newChange2(PersonIdent ident) throws Exception {
|
||||||
PushOneCommit push =
|
PushOneCommit push =
|
||||||
pushFactory.create(db, ident, testRepo, PushOneCommit.SUBJECT, FILE_NAME,
|
pushFactory.create(db, ident, testRepo, PushOneCommit.SUBJECT, FILE_NAME,
|
||||||
new String(CONTENT_OLD, StandardCharsets.UTF_8));
|
new String(CONTENT_OLD, UTF_8));
|
||||||
return push.rm("refs/for/master").getChangeId();
|
return push.rm("refs/for/master").getChangeId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
package com.google.gerrit.acceptance.pgm;
|
package com.google.gerrit.acceptance.pgm;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import com.google.gerrit.launcher.GerritLauncher;
|
import com.google.gerrit.launcher.GerritLauncher;
|
||||||
@ -26,7 +27,6 @@ import org.junit.Before;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
public class RebuildNotedbIT {
|
public class RebuildNotedbIT {
|
||||||
private File sitePath;
|
private File sitePath;
|
||||||
@ -48,7 +48,7 @@ public class RebuildNotedbIT {
|
|||||||
initSite();
|
initSite();
|
||||||
Files.append(NotesMigration.allEnabledConfig().toText(),
|
Files.append(NotesMigration.allEnabledConfig().toText(),
|
||||||
new File(sitePath.toString(), "etc/gerrit.config"),
|
new File(sitePath.toString(), "etc/gerrit.config"),
|
||||||
StandardCharsets.UTF_8);
|
UTF_8);
|
||||||
runGerrit("RebuildNotedb", "-d", sitePath.toString(),
|
runGerrit("RebuildNotedb", "-d", sitePath.toString(),
|
||||||
"--show-stack-trace");
|
"--show-stack-trace");
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.httpd.auth.oauth;
|
package com.google.gerrit.httpd.auth.oauth;
|
||||||
|
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
@ -32,7 +34,6 @@ import org.w3c.dom.Document;
|
|||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
@ -183,7 +184,7 @@ class OAuthWebFilter implements Filter {
|
|||||||
byte[] bin = HtmlDomUtil.toUTF8(doc);
|
byte[] bin = HtmlDomUtil.toUTF8(doc);
|
||||||
res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||||
res.setContentType("text/html");
|
res.setContentType("text/html");
|
||||||
res.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
res.setCharacterEncoding(UTF_8.name());
|
||||||
res.setContentLength(bin.length);
|
res.setContentLength(bin.length);
|
||||||
try (ServletOutputStream out = res.getOutputStream()) {
|
try (ServletOutputStream out = res.getOutputStream()) {
|
||||||
out.write(bin);
|
out.write(bin);
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.pgm.init;
|
package com.google.gerrit.pgm.init;
|
||||||
|
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.gerrit.common.TimeUtil;
|
import com.google.gerrit.common.TimeUtil;
|
||||||
import com.google.gerrit.pgm.init.api.ConsoleUI;
|
import com.google.gerrit.pgm.init.api.ConsoleUI;
|
||||||
@ -32,7 +34,6 @@ import com.google.inject.Inject;
|
|||||||
import org.apache.commons.validator.routines.EmailValidator;
|
import org.apache.commons.validator.routines.EmailValidator;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
@ -153,7 +154,7 @@ public class InitAdminUser implements InitStep {
|
|||||||
throw new IOException(String.format(
|
throw new IOException(String.format(
|
||||||
"Cannot add public SSH key: %s is not a file", keyFile));
|
"Cannot add public SSH key: %s is not a file", keyFile));
|
||||||
}
|
}
|
||||||
String content = new String(Files.readAllBytes(p), StandardCharsets.UTF_8);
|
String content = new String(Files.readAllBytes(p), UTF_8);
|
||||||
return new AccountSshKey(new AccountSshKey.Id(id, 0), content);
|
return new AccountSshKey(new AccountSshKey.Id(id, 0), content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.sshd.commands;
|
package com.google.gerrit.sshd.commands;
|
||||||
|
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.io.CharStreams;
|
import com.google.common.io.CharStreams;
|
||||||
@ -50,7 +52,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -249,8 +250,7 @@ public class ReviewCommand extends SshCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ReviewInput reviewFromJson() throws UnloggedFailure {
|
private ReviewInput reviewFromJson() throws UnloggedFailure {
|
||||||
try (InputStreamReader r =
|
try (InputStreamReader r = new InputStreamReader(in, UTF_8)) {
|
||||||
new InputStreamReader(in, StandardCharsets.UTF_8)) {
|
|
||||||
return OutputFormat.JSON.newGson().
|
return OutputFormat.JSON.newGson().
|
||||||
fromJson(CharStreams.toString(r), ReviewInput.class);
|
fromJson(CharStreams.toString(r), ReviewInput.class);
|
||||||
} catch (IOException | JsonSyntaxException e) {
|
} catch (IOException | JsonSyntaxException e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user