17
17
import java .util .Objects ;
18
18
import javax .net .ssl .SSLEngine ;
19
19
20
- import com .fasterxml .jackson .databind .ObjectMapper ;
21
20
import org .apache .hc .client5 .http .auth .AuthScope ;
22
21
import org .apache .hc .client5 .http .auth .UsernamePasswordCredentials ;
23
22
import org .apache .hc .client5 .http .impl .auth .BasicCredentialsProvider ;
42
41
import org .opensearch .common .settings .Settings ;
43
42
import org .opensearch .common .util .io .IOUtils ;
44
43
import org .opensearch .core .common .Strings ;
44
+ import org .opensearch .core .xcontent .MediaTypeRegistry ;
45
+ import org .opensearch .core .xcontent .XContentBuilder ;
45
46
import org .opensearch .customcodecs .bwc .helper .RestHelper ;
46
47
import org .opensearch .test .rest .OpenSearchRestTestCase ;
47
48
@@ -185,7 +186,6 @@ public void testDataIngestionAndSearchBackwardsCompatibility() throws Exception
185
186
private void ingestData (String index ) throws IOException {
186
187
assertTrue (indexExists (index ));
187
188
StringBuilder bulkRequestBody = new StringBuilder ();
188
- ObjectMapper objectMapper = new ObjectMapper ();
189
189
int numberOfRequests = Randomness .get ().nextInt (10 );
190
190
while (numberOfRequests -- > 0 ) {
191
191
for (int i = 0 ; i < Randomness .get ().nextInt (100 ); i ++) {
@@ -195,8 +195,13 @@ private void ingestData(String index) throws IOException {
195
195
put ("_index" , index );
196
196
}
197
197
});
198
- bulkRequestBody .append (objectMapper .writeValueAsString (indexRequest ) + "\n " );
199
- bulkRequestBody .append (objectMapper .writeValueAsString (Song .randomSong ().asJson ()) + "\n " );
198
+
199
+ try (final XContentBuilder contentBuilder = MediaTypeRegistry .JSON .contentBuilder ()) {
200
+ contentBuilder .map (indexRequest );
201
+ bulkRequestBody .append (contentBuilder .toString () + "\n " );
202
+ }
203
+
204
+ bulkRequestBody .append (Song .randomSong ().asJson () + "\n " );
200
205
}
201
206
List <Response > responses = RestHelper .requestAgainstAllNodes (
202
207
testUserRestClient ,
0 commit comments