55package com .microsoft .azure .documentdb ;
66
77import java .io .InputStream ;
8- import java .io . UnsupportedEncodingException ;
8+ import java .nio . charset . StandardCharsets ;
99import java .util .HashMap ;
1010import java .util .Map ;
1111
@@ -98,12 +98,8 @@ public static DocumentServiceRequest create(ResourceType resourceType,
9898 String relativePath ,
9999 Resource resource ,
100100 Map <String , String > headers ) {
101- try {
102- HttpEntity body = new StringEntity (resource .toString ());
103- return new DocumentServiceRequest (resourceType , relativePath , body , headers );
104- } catch (UnsupportedEncodingException e ) {
105- throw new IllegalArgumentException ("Failed to get HttpEntity from resource." , e );
106- }
101+ HttpEntity body = new StringEntity (resource .toString (), StandardCharsets .UTF_8 );
102+ return new DocumentServiceRequest (resourceType , relativePath , body , headers );
107103 }
108104
109105 /**
@@ -119,12 +115,8 @@ public static DocumentServiceRequest create(ResourceType resourceType,
119115 String relativePath ,
120116 String query ,
121117 Map <String , String > headers ) {
122- try {
123- HttpEntity body = new StringEntity (query );
124- return new DocumentServiceRequest (resourceType , relativePath , body , headers );
125- } catch (UnsupportedEncodingException e ) {
126- throw new IllegalArgumentException ("Failed to get HttpEntity from resource." , e );
127- }
118+ HttpEntity body = new StringEntity (query , StandardCharsets .UTF_8 );
119+ return new DocumentServiceRequest (resourceType , relativePath , body , headers );
128120 }
129121
130122 /**
@@ -160,12 +152,8 @@ public static DocumentServiceRequest create(ResourceType resourceType,
160152 break ;
161153 }
162154
163- try {
164- HttpEntity body = new StringEntity (queryText );
165- return new DocumentServiceRequest (resourceType , relativePath , body , headers );
166- } catch (UnsupportedEncodingException e ) {
167- throw new IllegalArgumentException ("Failed to get HttpEntity from resource." , e );
168- }
155+ HttpEntity body = new StringEntity (queryText , StandardCharsets .UTF_8 );
156+ return new DocumentServiceRequest (resourceType , relativePath , body , headers );
169157 }
170158
171159 /**
0 commit comments