[bugfix](es-catalog)fix exception when querying ES table (#26788)
This commit is contained in:
@ -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;
|
||||
|
||||
@ -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());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user