[bugfix](es-catalog)fix exception when querying ES table (#26788)

This commit is contained in:
Guangdong Liu
2023-11-14 10:47:37 +08:00
committed by GitHub
parent cd7ad99de0
commit e0934166f5
2 changed files with 16 additions and 1 deletions

View File

@ -110,7 +110,11 @@ public class EsNodeInfo {
String[] scratch = seed.split(":");
int port = 80;
if (scratch.length == 3) {
port = Integer.parseInt(scratch[2]);
String portStr = scratch[2];
if (portStr.contains("/")) {
portStr = portStr.substring(0, portStr.indexOf('/'));
}
port = Integer.parseInt(portStr);
}
String remoteHost = scratch[0] + ":" + scratch[1];
this.name = remoteHost;

View File

@ -43,4 +43,15 @@ public class EsNodeInfoTest extends EsTestCase {
}
}
}
@Test
public void testEsNodeInfo() {
EsNodeInfo node = new EsNodeInfo("0", "http://127.0.0.1:9200/");
Assert.assertEquals("http://127.0.0.1", node.getHost());
Assert.assertEquals(9200, node.getPublishAddress().getPort());
node = new EsNodeInfo("0", "http://127.0.0.1:9200");
Assert.assertEquals("http://127.0.0.1", node.getHost());
Assert.assertEquals(9200, node.getPublishAddress().getPort());
}
}