From 6f5db7f8527dae6b74ab9a09a086a217d64851e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=9F=D0=BE?= =?UTF-8?q?=D0=BB=D0=B5=D1=82=D0=B0=D0=B5=D0=B2?= Date: Fri, 8 Jan 2021 20:16:21 +0300 Subject: [PATCH] Force using UTF-8 for error messages --- src/main/java/Diadoc/Api/httpClient/DiadocHttpClient.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/Diadoc/Api/httpClient/DiadocHttpClient.java b/src/main/java/Diadoc/Api/httpClient/DiadocHttpClient.java index a59ea39f..82826ced 100644 --- a/src/main/java/Diadoc/Api/httpClient/DiadocHttpClient.java +++ b/src/main/java/Diadoc/Api/httpClient/DiadocHttpClient.java @@ -30,6 +30,7 @@ import javax.mail.internet.ParseException; import java.io.IOException; import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; @@ -112,7 +113,7 @@ private byte[] getResponseBytes(HttpResponse response) throws IOException { if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { throw new HttpResponseException( response.getStatusLine().getStatusCode(), - new String(IOUtils.toByteArray(response.getEntity().getContent()))); + new String(IOUtils.toByteArray(response.getEntity().getContent()), StandardCharsets.UTF_8)); } return IOUtils.toByteArray(response.getEntity().getContent()); } @@ -121,7 +122,7 @@ private DiadocResponseInfo getResponse(HttpResponse response) throws IOException if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { return DiadocResponseInfo.fail( response.getStatusLine().getStatusCode(), - new String(IOUtils.toByteArray(response.getEntity().getContent())), + new String(IOUtils.toByteArray(response.getEntity().getContent()), StandardCharsets.UTF_8), tryGetRetryAfter(response)); } return DiadocResponseInfo.success(IOUtils.toByteArray(response.getEntity().getContent()), response.getStatusLine().getStatusCode());