CheckOperationsImpl: Fix DefaultCharset warning
When all error prone warnings are enabled the DefaultCharset bug
pattern is reported:
CheckOperationsImpl.java:103: error: [DefaultCharset] Implicit use of \
the platform default charset, which can result in differing behaviour \
between JVM executions or incorrect behavior if the encoding of the \
data source doesn't match expectations.
note.copy(), new String(notes.getCachedBytes(note.toObjectId(), Integer.MAX_VALUE)));
^
(see https://errorprone.info/bugpattern/DefaultCharset)
Change-Id: I64571d9d4ca2447f4c2b2e92be7ab3eb43df9c51
diff --git a/java/com/google/gerrit/plugins/checks/acceptance/testsuite/CheckOperationsImpl.java b/java/com/google/gerrit/plugins/checks/acceptance/testsuite/CheckOperationsImpl.java
index c732548..310af7a 100644
--- a/java/com/google/gerrit/plugins/checks/acceptance/testsuite/CheckOperationsImpl.java
+++ b/java/com/google/gerrit/plugins/checks/acceptance/testsuite/CheckOperationsImpl.java
@@ -15,6 +15,7 @@
package com.google.gerrit.plugins.checks.acceptance.testsuite;
import static com.google.common.base.Preconditions.checkNotNull;
+import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@@ -100,7 +101,8 @@
for (Note note : notes) {
raw.put(
- note.copy(), new String(notes.getCachedBytes(note.toObjectId(), Integer.MAX_VALUE)));
+ note.copy(),
+ new String(notes.getCachedBytes(note.toObjectId(), Integer.MAX_VALUE), UTF_8));
}
return raw.build();
}