[errorprone] Fix DefaultCharset warning in BareSuperprojectWriterTest

Set the string encoding when converting a byte array into String,
avoiding the build-time warning on platform-dependent encoding.

See https://errorprone.info/bugpattern/DefaultCharset

Change-Id: I1f920043a8f303da43a8278793c38453e8773d69
This commit is contained in:
Luca Milanesio 2022-02-03 01:20:19 +00:00 committed by Matthias Sohn
parent 20bdcf9ea8
commit d0553759a0
1 changed files with 3 additions and 1 deletions

View File

@ -15,6 +15,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
@ -97,7 +98,8 @@ private String readContents(Repository repo, RevCommit commit,
ObjectId modId = repo.resolve(idStr);
try (ObjectReader reader = repo.newObjectReader()) {
return new String(
reader.open(modId).getCachedBytes(Integer.MAX_VALUE));
reader.open(modId).getCachedBytes(Integer.MAX_VALUE),
StandardCharsets.UTF_8);
}
}