Skip to content
This repository was archived by the owner on Jan 31, 2022. It is now read-only.

Commit 4034a6c

Browse files
committed
Index: explicitly decoding as UTF-8
1 parent d434bef commit 4034a6c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

algoliasearch/src/main/java/com/algolia/search/saas/BaseAPIClient.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ private JSONObject _getJSONObject(String input) throws JSONException {
377377
return new JSONObject(new JSONTokener(input));
378378
}
379379

380-
private JSONObject _getJSONObject(byte[] array) throws JSONException {
381-
return new JSONObject(new JSONTokener(new String(array)));
380+
private JSONObject _getJSONObject(byte[] array) throws JSONException, UnsupportedEncodingException {
381+
return new JSONObject(new String(array, "UTF-8"));
382382
}
383383

384384
private JSONObject _getAnswerJSONObject(InputStream istream) throws IOException, JSONException {
@@ -402,6 +402,8 @@ private synchronized JSONObject _request(Method m, String url, String json, List
402402
return _getJSONObject(_requestRaw(m, url, json, hostsArray, connectTimeout, readTimeout));
403403
} catch (JSONException e) {
404404
throw new AlgoliaException("JSON decode error:" + e.getMessage());
405+
} catch (UnsupportedEncodingException e) {
406+
throw new AlgoliaException("UTF-8 decode error:" + e.getMessage());
405407
}
406408
}
407409

0 commit comments

Comments
 (0)