From 90292f2b6f20beedf50e81b68f6223d411752f72 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Thu, 16 May 2024 12:27:43 +0400 Subject: [PATCH] [DOCS] Add transport.close() to connecting page (#807) * [DOCS] Add transport.close() to connecting page Without this line, the code hangs because the HttpClient thread keeps running indefinitely. * Replace tabs with spaces --- .../getting_started/ConnectingTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/java-client/src/test/java/co/elastic/clients/documentation/getting_started/ConnectingTest.java b/java-client/src/test/java/co/elastic/clients/documentation/getting_started/ConnectingTest.java index 4e2bb87a6..c779ab745 100644 --- a/java-client/src/test/java/co/elastic/clients/documentation/getting_started/ConnectingTest.java +++ b/java-client/src/test/java/co/elastic/clients/documentation/getting_started/ConnectingTest.java @@ -67,6 +67,11 @@ public void createClient() throws Exception { // And create the API client ElasticsearchClient esClient = new ElasticsearchClient(transport); + + // Use the client... + + // Close the transport, freeing the underlying thread + transport.close(); //end::create-client //tag::first-request @@ -115,6 +120,11 @@ restClient, new JacksonJsonpMapper(), null, esOtelInstrumentation // And create the API client ElasticsearchClient esClient = new ElasticsearchClient(transport); + + // Use the client... + + // Close the transport, freeing the underlying thread + transport.close(); //end::create-client-otel } @@ -150,6 +160,11 @@ AuthScope.ANY, new UsernamePasswordCredentials(login, password) // Create the transport and the API client ElasticsearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper()); ElasticsearchClient client = new ElasticsearchClient(transport); + + // Use the client... + + // Close the transport, freeing the underlying thread + transport.close(); //end::create-secure-client-cert } @@ -185,6 +200,11 @@ AuthScope.ANY, new UsernamePasswordCredentials(login, password) // Create the transport and the API client ElasticsearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper()); ElasticsearchClient client = new ElasticsearchClient(transport); + + // Use the client... + + // Close the transport, freeing the underlying thread + transport.close(); //end::create-secure-client-fingerprint }