1818import org .elasticsearch .common .settings .Settings ;
1919import org .elasticsearch .common .xcontent .XContentHelper ;
2020import org .elasticsearch .core .IOUtils ;
21- import org .elasticsearch .core .TimeValue ;
2221import org .elasticsearch .geometry .Geometry ;
2322import org .elasticsearch .geometry .Point ;
2423import org .elasticsearch .geometry .utils .GeometryValidator ;
@@ -263,14 +262,13 @@ public void evaluate() throws Throwable {
263262 }
264263
265264 public static class TestRuleRestClient implements TestRule {
266- private static final long CLIENT_TIMEOUT = 40L ;
267265 private ElasticsearchCluster cluster ;
268- private Settings clientAuthSettings ;
266+ private Settings clientSettings ;
269267 private RestClient client ;
270268
271- public TestRuleRestClient (ElasticsearchCluster cluster , Settings clientAuthSettings ) {
269+ public TestRuleRestClient (ElasticsearchCluster cluster , Settings clientSettings ) {
272270 this .cluster = cluster ;
273- this .clientAuthSettings = clientAuthSettings ;
271+ this .clientSettings = clientSettings ;
274272 }
275273
276274 public TestRuleRestClient (ElasticsearchCluster cluster ) {
@@ -296,7 +294,6 @@ public void evaluate() throws Throwable {
296294 };
297295 }
298296
299- // TODO: See if we can use existing code for building the client
300297 private RestClient doStartClient () throws IOException {
301298 String address = cluster .getHttpAddress (0 );
302299 int portSeparator = address .lastIndexOf (':' );
@@ -305,25 +302,14 @@ private RestClient doStartClient() throws IOException {
305302 }
306303 String host = address .substring (0 , portSeparator );
307304 int port = Integer .parseInt (address .substring (portSeparator + 1 ));
308- HttpHost [] remoteHttpHosts = new HttpHost [] { new HttpHost (host , port ) };
305+ HttpHost [] httpHosts = new HttpHost [] { new HttpHost (host , port ) };
309306
310- return clientBuilder ( clientAuthSettings , remoteHttpHosts );
307+ return buildClient ( clientSettings , httpHosts );
311308 }
312309
313- protected static TimeValue timeout () {
314- return TimeValue .timeValueSeconds (CLIENT_TIMEOUT );
315- }
316-
317- private static RestClient clientBuilder (Settings settings , HttpHost [] hosts ) throws IOException {
310+ private static RestClient buildClient (Settings settings , HttpHost [] hosts ) throws IOException {
318311 RestClientBuilder builder = RestClient .builder (hosts );
319312 doConfigureClient (builder , settings );
320-
321- int timeout = Math .toIntExact (timeout ().millis ());
322- builder .setRequestConfigCallback (
323- requestConfigBuilder -> requestConfigBuilder .setConnectTimeout (timeout )
324- .setConnectionRequestTimeout (timeout )
325- .setSocketTimeout (timeout )
326- );
327313 builder .setStrictDeprecationMode (true );
328314 return builder .build ();
329315 }
0 commit comments