Fixed JiraRestApi writeBodyData not encoding String to UTF-8
Fixed JiraRestApi.writeBodyData method not encoding bytes to UTF-8
As a result national characters like "gęś" was encoded as "g??" on
output, i.e. inside Jira comments
Bug: Issue 40011709
Change-Id: Ia33b574162cfc8d7c037bb65d80c85f70218b125
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/jira/restapi/JiraRestApi.java b/src/main/java/com/googlesource/gerrit/plugins/its/jira/restapi/JiraRestApi.java
index c24ff49..af89214 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/jira/restapi/JiraRestApi.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/jira/restapi/JiraRestApi.java
@@ -13,6 +13,7 @@
// limitations under the License.
package com.googlesource.gerrit.plugins.its.jira.restapi;
+import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.gson.Gson;
import com.google.inject.Inject;
@@ -135,7 +136,7 @@
private void writeBodyData(String data, HttpURLConnection conn) throws IOException {
if (data != null) {
try (OutputStream os = conn.getOutputStream()) {
- os.write(data.getBytes());
+ os.write(data.getBytes(UTF_8));
os.flush();
}
}