Fix bug that inconsistency happens in long value and name in PortNumber

The case is like the underlying name is "2", but long value is 0.

This fix relates to ONOS-2082.

Change-Id: I702ed91563296d38980dc6895fafb18aecaa26f8
This commit is contained in:
Sho SHIMIZU 2015-06-11 16:55:20 -07:00 committed by Gerrit Code Review
parent a2413b5f58
commit ccf40c722b

View File

@ -517,13 +517,20 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
String portName = text.substring(i + 1);
DeviceId deviceId = deviceId(text.substring(0, i));
long portNum = 0L;
for (Port port : deviceService.getPorts(deviceId)) {
PortNumber pn = port.number();
if (pn.name().equals(portName)) {
return new ConnectPoint(deviceId, pn);
}
}
long portNum;
try {
portNum = Long.parseLong(portName);
} catch (NumberFormatException e) {
portNum = 0;
}
return new ConnectPoint(deviceId, portNumber(portNum, portName));
}