Fix Java client example (#6438)

The syntax provided for the second example at https://opensearch.org/docs/latest/clients/java/#initializing-the-client-with-ssl-and-tls-enabled-using-restclient-transport is invalid:
 - hostname and port order are reversed
 - the password field is a character array

The correct syntax is used earlier on the page for the Apache HTTP client version.

Signed-off-by: Daniel Widdis <widdis@gmail.com>
This commit is contained in:
Daniel Widdis 2024-02-19 10:56:03 -08:00 committed by GitHub
parent 9af42a86f4
commit 93878a9e29
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -222,10 +222,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", 9200, "localhost");
final HttpHost host = new HttpHost("https", "localhost", 9200);
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"));
credentialsProvider.setCredentials(new AuthScope(host), new UsernamePasswordCredentials("admin", "admin".toCharArray()));
//Initialize the client with SSL and TLS enabled
final RestClient restClient = RestClient.builder(host).