Fixes #38: Enhance error handling when parsing bad dashboard addresses
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
This commit is contained in:
parent
fd936a4567
commit
35c5bad3e4
|
|
@ -101,21 +101,29 @@ public class SimpleHttpHeartbeatSender implements HeartbeatSender {
|
||||||
|
|
||||||
private List<InetSocketAddress> getDefaultConsoleIps() {
|
private List<InetSocketAddress> getDefaultConsoleIps() {
|
||||||
List<InetSocketAddress> newAddrs = new ArrayList<InetSocketAddress>();
|
List<InetSocketAddress> newAddrs = new ArrayList<InetSocketAddress>();
|
||||||
String ipsStr = TransportConfig.getConsoleServer();
|
try {
|
||||||
if (StringUtil.isEmpty(ipsStr)) {
|
String ipsStr = TransportConfig.getConsoleServer();
|
||||||
return newAddrs;
|
if (StringUtil.isEmpty(ipsStr)) {
|
||||||
}
|
return newAddrs;
|
||||||
|
}
|
||||||
|
|
||||||
for (String ipPortStr : ipsStr.split(",")) {
|
for (String ipPortStr : ipsStr.split(",")) {
|
||||||
if (ipPortStr.trim().length() == 0) {
|
if (ipPortStr.trim().length() == 0) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
if (ipPortStr.startsWith("http://")) {
|
||||||
|
ipPortStr = ipPortStr.trim().substring(7);
|
||||||
|
}
|
||||||
|
String[] ipPort = ipPortStr.trim().split(":");
|
||||||
|
int port = 80;
|
||||||
|
if (ipPort.length > 1) {
|
||||||
|
port = Integer.parseInt(ipPort[1].trim());
|
||||||
|
}
|
||||||
|
newAddrs.add(new InetSocketAddress(ipPort[0].trim(), port));
|
||||||
}
|
}
|
||||||
String[] ipPort = ipPortStr.trim().split(":");
|
} catch (Exception ex) {
|
||||||
int port = 80;
|
RecordLog.info("[SimpleHeartbeatSender] Parse console list failed, current address list: " + newAddrs, ex);
|
||||||
if (ipPort.length > 1) {
|
ex.printStackTrace();
|
||||||
port = Integer.parseInt(ipPort[1].trim());
|
|
||||||
}
|
|
||||||
newAddrs.add(new InetSocketAddress(ipPort[0].trim(), port));
|
|
||||||
}
|
}
|
||||||
return newAddrs;
|
return newAddrs;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue