[Bugfix](multi-catalog)If es hosts ends with "/", the index cannot be obtained. (#24272)

This commit is contained in:
Guangdong Liu
2023-09-20 20:35:14 +08:00
committed by GitHub
parent e4b551e2ce
commit 8aa39137fc
2 changed files with 11 additions and 9 deletions

View File

@ -56,14 +56,15 @@ import javax.net.ssl.X509TrustManager;
public class EsRestClient {
private static final Logger LOG = LogManager.getLogger(EsRestClient.class);
private static OkHttpClient networkClient = new OkHttpClient.Builder().readTimeout(10, TimeUnit.SECONDS).build();
private static final OkHttpClient networkClient = new OkHttpClient
.Builder().readTimeout(10, TimeUnit.SECONDS).build();
private static OkHttpClient sslNetworkClient;
private Request.Builder builder;
private String[] nodes;
private final Request.Builder builder;
private final String[] nodes;
private String currentNode;
private int currentNodeIndex = 0;
private boolean httpSslEnable;
private final boolean httpSslEnable;
/**
* For EsTable.
@ -129,9 +130,7 @@ public class EsRestClient {
**/
public boolean existIndex(OkHttpClient httpClient, String indexName) {
String path = indexName + "/_mapping";
Response response;
try {
response = executeResponse(httpClient, path);
try (Response response = executeResponse(httpClient, path)) {
if (response.isSuccessful()) {
return true;
}
@ -228,7 +227,10 @@ public class EsRestClient {
if (!(currentNode.startsWith("http://") || currentNode.startsWith("https://"))) {
currentNode = "http://" + currentNode;
}
Request request = builder.get().url(currentNode + "/" + path).build();
if (!currentNode.endsWith("/")) {
currentNode = currentNode + "/";
}
Request request = builder.get().url(currentNode + path).build();
if (LOG.isInfoEnabled()) {
LOG.info("es rest client request URL: {}", currentNode + "/" + path);
}

View File

@ -88,7 +88,7 @@ enableHiveTest=true
hms_port=7141
enableEsTest=true
es_6_port=19200
es_6_port="19200/"
es_7_port=29200
es_8_port=39200