Skip to content

Commit

Permalink
Fixes alibaba#38: Enhance error handling when parsing bad dashboard a…
Browse files Browse the repository at this point in the history
…ddresses

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
  • Loading branch information
sczyh30 committed Aug 6, 2018
1 parent fd936a4 commit 35c5bad
Showing 1 changed file with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,29 @@ private InetSocketAddress getAvailableAddress() {

private List<InetSocketAddress> getDefaultConsoleIps() {
List<InetSocketAddress> newAddrs = new ArrayList<InetSocketAddress>();
String ipsStr = TransportConfig.getConsoleServer();
if (StringUtil.isEmpty(ipsStr)) {
return newAddrs;
}

for (String ipPortStr : ipsStr.split(",")) {
if (ipPortStr.trim().length() == 0) {
continue;
try {
String ipsStr = TransportConfig.getConsoleServer();
if (StringUtil.isEmpty(ipsStr)) {
return newAddrs;
}
String[] ipPort = ipPortStr.trim().split(":");
int port = 80;
if (ipPort.length > 1) {
port = Integer.parseInt(ipPort[1].trim());

for (String ipPortStr : ipsStr.split(",")) {
if (ipPortStr.trim().length() == 0) {
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));
}
newAddrs.add(new InetSocketAddress(ipPort[0].trim(), port));
} catch (Exception ex) {
RecordLog.info("[SimpleHeartbeatSender] Parse console list failed, current address list: " + newAddrs, ex);
ex.printStackTrace();
}
return newAddrs;
}
Expand Down

0 comments on commit 35c5bad

Please sign in to comment.