diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/GitUtil.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/GitUtil.java index 494f094bc7..dee36ef0be 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/GitUtil.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/GitUtil.java @@ -46,8 +46,10 @@ import org.eclipse.jgit.util.FS; import java.io.BufferedWriter; import java.io.File; -import java.io.FileWriter; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Properties; @@ -128,8 +130,9 @@ public class GitUtil { if (!p.exists() && !p.mkdirs()) { throw new IOException("failed to create dir: " + p.getAbsolutePath()); } - FileWriter w = new FileWriter(f); - BufferedWriter out = new BufferedWriter(w); + FileOutputStream s = new FileOutputStream(f); + BufferedWriter out = new BufferedWriter( + new OutputStreamWriter(s, StandardCharsets.UTF_8)); try { out.write(content); } finally { diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/edit/ChangeEditIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/edit/ChangeEditIT.java index f16c677790..4726079319 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/edit/ChangeEditIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/edit/ChangeEditIT.java @@ -72,6 +72,7 @@ import org.junit.Test; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Date; import java.util.List; import java.util.concurrent.atomic.AtomicLong; @@ -656,21 +657,21 @@ public class ChangeEditIT extends AbstractDaemonTest { private String newChange(Git git, PersonIdent ident) throws Exception { PushOneCommit push = pushFactory.create(db, ident, PushOneCommit.SUBJECT, FILE_NAME, - new String(CONTENT_OLD)); + new String(CONTENT_OLD, StandardCharsets.UTF_8)); return push.to(git, "refs/for/master").getChangeId(); } private String amendChange(Git git, PersonIdent ident, String changeId) throws Exception { PushOneCommit push = pushFactory.create(db, ident, PushOneCommit.SUBJECT, FILE_NAME2, - new String(CONTENT_NEW2), changeId); + new String(CONTENT_NEW2, StandardCharsets.UTF_8), changeId); return push.to(git, "refs/for/master").getChangeId(); } private String newChange2(Git git, PersonIdent ident) throws Exception { PushOneCommit push = pushFactory.create(db, ident, PushOneCommit.SUBJECT, FILE_NAME, - new String(CONTENT_OLD)); + new String(CONTENT_OLD, StandardCharsets.UTF_8)); return push.rm(git, "refs/for/master").getChangeId(); }