[VOL-1457] Fix the adapter callback exception
Change-Id: If8599a1a2e232723b765a530bf2a8d83043c03de
diff --git a/rw_core/core/adapter_manager.go b/rw_core/core/adapter_manager.go
index c0ec1e9..d4d3c69 100644
--- a/rw_core/core/adapter_manager.go
+++ b/rw_core/core/adapter_manager.go
@@ -327,19 +327,26 @@
var ok bool
if previousData, ok = args[0].(*voltha.Adapters); !ok {
log.Errorw("invalid-args", log.Fields{"args0": args[0]})
+ return nil
}
if latestData, ok = args[1].(*voltha.Adapters); !ok {
log.Errorw("invalid-args", log.Fields{"args1": args[1]})
- }
-
- if reflect.DeepEqual(previousData.Items, latestData.Items) {
- log.Debug("update-not-required")
return nil
}
- for _, adapter := range latestData.Items {
- aMgr.updateAdapter(adapter)
+ if previousData != nil && latestData != nil {
+ if reflect.DeepEqual(previousData.Items, latestData.Items) {
+ log.Debug("update-not-required")
+ return nil
+ }
}
+
+ if latestData != nil {
+ for _, adapter := range latestData.Items {
+ aMgr.updateAdapter(adapter)
+ }
+ }
+
return nil
}
@@ -353,18 +360,25 @@
var ok bool
if previousData, ok = args[0].(*voltha.DeviceTypes); !ok {
log.Errorw("invalid-args", log.Fields{"args0": args[0]})
- }
- if latestData, ok = args[1].(*voltha.DeviceTypes); !ok {
- log.Errorw("invalid-args", log.Fields{"args1": args[1]})
- }
-
- if reflect.DeepEqual(previousData.Items, latestData.Items) {
- log.Debug("update-not-required")
return nil
}
- for _, dType := range latestData.Items {
- aMgr.updateDeviceType(dType)
+ if latestData, ok = args[1].(*voltha.DeviceTypes); !ok {
+ log.Errorw("invalid-args", log.Fields{"args1": args[1]})
+ return nil
+ }
+
+ if previousData != nil && latestData != nil {
+ if reflect.DeepEqual(previousData.Items, latestData.Items) {
+ log.Debug("update-not-required")
+ return nil
+ }
+ }
+
+ if latestData != nil {
+ for _, dType := range latestData.Items {
+ aMgr.updateDeviceType(dType)
+ }
}
return nil
}
\ No newline at end of file