3939import java .io .IOException ;
4040import java .io .InputStream ;
4141import java .io .OutputStream ;
42+ import java .io .UnsupportedEncodingException ;
4243import java .net .URL ;
4344import java .util .List ;
4445import java .util .Map ;
@@ -58,6 +59,11 @@ public class DefaultHttpProvider implements IHttpProvider {
5859 * The content type for JSON responses
5960 */
6061 static final String JSON_CONTENT_TYPE = "application/json" ;
62+
63+ /**
64+ * The encoding type for getBytes
65+ */
66+ static final String ENCODING_TYPE = "UTF-8" ;
6167
6268 /**
6369 * The serializer
@@ -254,7 +260,7 @@ private <Result, Body, DeserializeType> Result sendRequestInternal(final IHttpRe
254260 } else {
255261 logger .logDebug ("Sending " + serializable .getClass ().getName () + " as request body" );
256262 final String serializeObject = serializer .serializeObject (serializable );
257- bytesToWrite = serializeObject .getBytes ("UTF-8" );
263+ bytesToWrite = serializeObject .getBytes (ENCODING_TYPE );
258264
259265 // If the user hasn't specified a Content-Type for the request
260266 if (!hasHeader (requestHeaders , CONTENT_TYPE_HEADER_NAME )) {
@@ -403,7 +409,13 @@ private <Result> Result handleJsonResponse(final InputStream in, Map<String, Lis
403409 */
404410 private <Result > Result handleEmptyResponse (Map <String , List <String >> responseHeaders , final Class <Result > clazz ) {
405411 //Create an empty object to attach the response headers to
406- InputStream in = new ByteArrayInputStream ("{}" .getBytes ());
412+ InputStream in = null ;
413+ try {
414+ in = new ByteArrayInputStream ("{}" .getBytes (ENCODING_TYPE ));
415+ }
416+ catch (UnsupportedEncodingException ex ) {
417+ ex .printStackTrace ();
418+ }
407419
408420 return handleJsonResponse (in , responseHeaders , clazz );
409421 }
0 commit comments