You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/09/20 14:07:17 UTC
[GitHub] [skywalking] wuguanyu edited a comment on issue #7758: [Bug] java.lang.NumberFormatException in MysqlURLParser
wuguanyu edited a comment on issue #7758:
URL: https://github.com/apache/skywalking/issues/7758#issuecomment-922958662
@Override
public ConnectionInfo parse() {
URLLocation location = fetchDatabaseHostsIndexRange();
String hosts = url.substring(location.startIndex(), location.endIndex());
String[] hostSegment = hosts.split(",");
if (hostSegment.length > 1) {
StringBuilder sb = new StringBuilder();
for (String host : hostSegment) {
if (host.split(":").length == 1) {
sb.append(host).append(":").append(DEFAULT_PORT).append(",");
} else {
sb.append(host).append(",");
}
}
return new ConnectionInfo(component, dbType, sb.substring(0, sb.length() - 1), fetchDatabaseNameFromURL());
} else {
String[] hostAndPort = hostSegment[0].split(":");
if (hostAndPort.length != 1) {
return new ConnectionInfo(component, dbType, hostAndPort[0], Integer.valueOf(hostAndPort[1]), fetchDatabaseNameFromURL(location
.endIndex()));
} else {
return new ConnectionInfo(component, dbType, hostAndPort[0], DEFAULT_PORT, fetchDatabaseNameFromURL(location
.endIndex()));
}
}
}
The following java code throw NumberFormat exception Beacause of jdbcUrl have no db information
**
> `Integer.valueOf(hostAndPort[1])`
**
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org