Uploaded image for project: 'Spring Data Elasticsearch'
  1. Spring Data Elasticsearch
  2. DATAES-776

Adapt RestClients class to change in InetSocketAddress class in JDK14

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 4.0 RC1 (Neumann)
    • Component/s: Core
    • Labels:
      None
    • Environment:
      JDK 14

      Description

      I have a project where I'm creating a RestHighLevelClient bean using ClientConfiguration builder like this:

      final ClientConfiguration clientConfiguration = ClientConfiguration.builder()  .connectedTo("localhost:9200").build();
      

       
      However, when RestClients.java parses the host, it converts the InetSocketAddress where the host information is stored to a String, with which seems the implicit toString() method:

      org.springframework.data.elasticsearch.client.RestClients.java
      
      private static List<String> formattedHosts(List<InetSocketAddress> hosts, 
      boolean useSsl) {
        return hosts.stream().map(it -> (useSsl ? "https" : "http") + "://" + it)
      .collect(Collectors.toList());
      }
      

      This results in something like 'https://localhost/<unresolved>:9200'. Notice that '<unresolved>' part. It's the 'addr' field of InetSocketAddress which is null.

      Because of this, ElasticSearch fails with a message like:

      Caused by: java.io.IOException: localhost/<unresolved>: Name or service not known    at org.elasticsearch.client.RestClient.extractAndWrapCause(RestClient.java:828)
      

      Am I using the ClientConfiguration correctly? I can see that code has been like that for a while. Or should that Stream.map do something like 'it.getHostName() + ":" + it.getPort()' instead?

      Thank you for the help. I can provide a pull request if needed.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sothawo sothawo
              Reporter:
              jquintana Juan Manuel de Blas
              Last updater:
              sothawo
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: