Skip to content

Commit

Permalink
Fix RestClientTransport code snippets (#4149) (#4150)
Browse files Browse the repository at this point in the history
(cherry picked from commit 3ff62a8)

Signed-off-by: Andriy Redko <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 29d5129 commit 67348e5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions _clients/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ This code example uses basic credentials that come with the default OpenSearch c
The following sample code initializes a client with SSL and TLS enabled:

```java
import org.apache.hc.client5.http.auth.AuthScope;
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
import org.apache.hc.client5.http.impl.async.HttpAsyncClientBuilder;
import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
import org.apache.hc.core5.http.HttpHost;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.opensearch.client.RestClient;
import org.opensearch.client.RestClientBuilder;
import org.opensearch.client.json.jackson.JacksonJsonpMapper;
Expand All @@ -215,10 +215,10 @@ public class OpenSearchClientExample {
System.setProperty("javax.net.ssl.trustStore", "/full/path/to/keystore");
System.setProperty("javax.net.ssl.trustStorePassword", "password-to-keystore");

final HttpHost host = new HttpHost("https", "localhost", 9200);
final HttpHost host = new HttpHost("https", 9200, "localhost");
final BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
//Only for demo purposes. Don't specify your credentials in code.
credentialsProvider.setCredentials(new AuthScope(host), new UsernamePasswordCredentials("admin", "admin".toCharArray()));
credentialsProvider.setCredentials(new AuthScope(host), new UsernamePasswordCredentials("admin", "admin"));

//Initialize the client with SSL and TLS enabled
final RestClient restClient = RestClient.builder(host).
Expand Down

0 comments on commit 67348e5

Please sign in to comment.