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
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;
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);
}
}