mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
optimize split IPAndPort
This commit is contained in:
@@ -9,6 +9,7 @@ import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import com.alibaba.otter.canal.common.utils.AddressUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -88,7 +89,7 @@ public class CanalRabbitMQConsumer implements CanalMsgConsumer {
|
||||
}
|
||||
// 解析出端口 modified by 16075140
|
||||
if (nameServer != null && nameServer.contains(":")) {
|
||||
String[] serverHostAndPort = nameServer.split(":");
|
||||
String[] serverHostAndPort = AddressUtils.splitIPAndPort(nameServer);
|
||||
factory.setHost(serverHostAndPort[0]);
|
||||
factory.setPort(Integer.parseInt(serverHostAndPort[1]));
|
||||
} else {
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.slf4j.LoggerFactory;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONWriter;
|
||||
import com.alibaba.otter.canal.common.CanalException;
|
||||
import com.alibaba.otter.canal.common.utils.AddressUtils;
|
||||
import com.alibaba.otter.canal.common.utils.ExecutorTemplate;
|
||||
import com.alibaba.otter.canal.common.utils.PropertiesUtils;
|
||||
import com.alibaba.otter.canal.connector.core.producer.AbstractMQProducer;
|
||||
@@ -61,7 +62,7 @@ public class CanalRabbitMQProducer extends AbstractMQProducer implements CanalMQ
|
||||
throw new CanalException("failed to parse host", ex);
|
||||
}
|
||||
} else if (servers.contains(":")) {
|
||||
String[] serverHostAndPort = servers.split(":");
|
||||
String[] serverHostAndPort = AddressUtils.splitIPAndPort(servers);
|
||||
factory.setHost(serverHostAndPort[0]);
|
||||
factory.setPort(Integer.parseInt(serverHostAndPort[1]));
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user