]> source.dussan.org Git - jgit.git/commitdiff
[errorprone] Fix DefaultCharset warning in BareSuperprojectWriterTest 51/190351/2
authorLuca Milanesio <luca.milanesio@gmail.com>
Thu, 3 Feb 2022 01:20:19 +0000 (01:20 +0000)
committerMatthias Sohn <matthias.sohn@sap.com>
Thu, 3 Feb 2022 23:29:17 +0000 (00:29 +0100)
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

org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/BareSuperprojectWriterTest.java

index 17fc8db35ee387423387d13a647077ccc51a3b88..c3b93879b28d8c512dbb93cb52201bd059d83a52 100644 (file)
@@ -15,6 +15,7 @@ import static org.hamcrest.Matchers.is;
 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 @@ public class BareSuperprojectWriterTest extends RepositoryTestCase {
                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);
 
                }
        }