make isGroupCapable exception safer
- Tricky part of DriverService API:
DriverService#getDriver(DeviceId) can either return null or throw exception when not found
DriverService#getDriver(String mfr, String hw, String sw) will return null when not found
- might fix ONOS-7558
Change-Id: I0a49ab1d94f12e7fda00aa5e8e4bc42820f67dfe
diff --git a/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProvider.java b/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProvider.java
index c60a58c..35ed436 100644
--- a/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProvider.java
+++ b/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProvider.java
@@ -36,6 +36,7 @@
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onlab.util.ItemNotFoundException;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.core.GroupId;
import org.onosproject.net.DeviceId;
@@ -382,12 +383,18 @@
* @return the boolean value of groupCapable property, or true if it is not configured.
*/
private boolean isGroupCapable(OpenFlowSwitch sw) {
- Driver driver = driverService.getDriver(DeviceId.deviceId(Dpid.uri(sw.getDpid())));
+ Driver driver;
+ try {
+ driver = driverService.getDriver(DeviceId.deviceId(Dpid.uri(sw.getDpid())));
+ } catch (ItemNotFoundException e) {
+ driver = driverService.getDriver(sw.manufacturerDescription(),
+ sw.hardwareDescription(),
+ sw.softwareDescription());
+ }
if (driver == null) {
return true;
}
- String isGroupCapable = driver.getProperty(GROUP_CAPABLE);
- return isGroupCapable == null || Boolean.parseBoolean(isGroupCapable);
+ return Boolean.parseBoolean(driver.getProperty(GROUP_CAPABLE));
}
private class InternalGroupProvider