You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2020/08/28 05:14:40 UTC

[GitHub] [calcite] danny0405 commented on a change in pull request #2123: Support for Elasticsearch basic authentication

danny0405 commented on a change in pull request #2123:
URL: https://github.com/apache/calcite/pull/2123#discussion_r478834432



##########
File path: elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchSchemaFactory.java
##########
@@ -100,14 +106,27 @@ public ElasticsearchSchemaFactory() {
   /**
    * Builds elastic rest client from user configuration
    * @param hosts list of ES HTTP Hosts to connect to
+   * @param jdbcUser the username of ES
+   * @param jdbcPassword the password of ES
    * @return newly initialized low-level rest http client for ES
    */
-  private static RestClient connect(List<HttpHost> hosts, String pathPrefix) {
+  private static RestClient connect(List<HttpHost> hosts, String pathPrefix, String jdbcUser,
+                                    String jdbcPassword) {
 
     Objects.requireNonNull(hosts, "hosts or coordinates");
     Preconditions.checkArgument(!hosts.isEmpty(), "no ES hosts specified");
 
     RestClientBuilder builder = RestClient.builder(hosts.toArray(new HttpHost[hosts.size()]));
+
+    if (jdbcUser != null && !jdbcUser.isEmpty()
+        && jdbcPassword != null && !jdbcPassword.isEmpty()) {

Review comment:
       you can use `Strings.isNullOrEmpty()`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org