Thomas Vachuska
Committed by Gerrit Code Review

Preventing NPEs in stores via notifyDelegate

Change-Id: I1c4b83c6a03b1f69a3ea1329724a7208d47cefa4
...@@ -101,9 +101,9 @@ public class DistributedComponentConfigStore ...@@ -101,9 +101,9 @@ public class DistributedComponentConfigStore
101 String[] keys = event.key().split(SEP); 101 String[] keys = event.key().split(SEP);
102 if (event.type() == INSERT || event.type() == UPDATE) { 102 if (event.type() == INSERT || event.type() == UPDATE) {
103 String value = event.newValue().value(); 103 String value = event.newValue().value();
104 - delegate.notify(new ComponentConfigEvent(PROPERTY_SET, keys[0], keys[1], value)); 104 + notifyDelegate(new ComponentConfigEvent(PROPERTY_SET, keys[0], keys[1], value));
105 } else if (event.type() == REMOVE) { 105 } else if (event.type() == REMOVE) {
106 - delegate.notify(new ComponentConfigEvent(PROPERTY_UNSET, keys[0], keys[1], null)); 106 + notifyDelegate(new ComponentConfigEvent(PROPERTY_UNSET, keys[0], keys[1], null));
107 } 107 }
108 } 108 }
109 } 109 }
......
...@@ -844,7 +844,7 @@ public class ECDeviceStore ...@@ -844,7 +844,7 @@ public class ECDeviceStore
844 if (event.type() == PUT) { 844 if (event.type() == PUT) {
845 Device device = devices.get(event.key()); 845 Device device = devices.get(event.key());
846 if (device != null) { 846 if (device != null) {
847 - delegate.notify(new DeviceEvent(PORT_STATS_UPDATED, device)); 847 + notifyDelegate(new DeviceEvent(PORT_STATS_UPDATED, device));
848 } 848 }
849 } 849 }
850 } 850 }
......
...@@ -1823,7 +1823,7 @@ public class GossipDeviceStore ...@@ -1823,7 +1823,7 @@ public class GossipDeviceStore
1823 if (event.type() == PUT) { 1823 if (event.type() == PUT) {
1824 Device device = devices.get(event.key()); 1824 Device device = devices.get(event.key());
1825 if (device != null) { 1825 if (device != null) {
1826 - delegate.notify(new DeviceEvent(PORT_STATS_UPDATED, device)); 1826 + notifyDelegate(new DeviceEvent(PORT_STATS_UPDATED, device));
1827 } 1827 }
1828 } 1828 }
1829 } 1829 }
......
...@@ -25,7 +25,6 @@ import org.onlab.util.KryoNamespace; ...@@ -25,7 +25,6 @@ import org.onlab.util.KryoNamespace;
25 import org.onosproject.net.ConnectPoint; 25 import org.onosproject.net.ConnectPoint;
26 import org.onosproject.net.mcast.McastEvent; 26 import org.onosproject.net.mcast.McastEvent;
27 import org.onosproject.net.mcast.McastRoute; 27 import org.onosproject.net.mcast.McastRoute;
28 -import org.onosproject.net.mcast.McastRouteInfo;
29 import org.onosproject.net.mcast.McastStore; 28 import org.onosproject.net.mcast.McastStore;
30 import org.onosproject.net.mcast.McastStoreDelegate; 29 import org.onosproject.net.mcast.McastStoreDelegate;
31 import org.onosproject.store.AbstractStore; 30 import org.onosproject.store.AbstractStore;
...@@ -39,6 +38,7 @@ import java.util.Map; ...@@ -39,6 +38,7 @@ import java.util.Map;
39 import java.util.Set; 38 import java.util.Set;
40 import java.util.concurrent.atomic.AtomicReference; 39 import java.util.concurrent.atomic.AtomicReference;
41 40
41 +import static org.onosproject.net.mcast.McastRouteInfo.mcastRouteInfo;
42 import static org.slf4j.LoggerFactory.getLogger; 42 import static org.slf4j.LoggerFactory.getLogger;
43 43
44 /** 44 /**
...@@ -96,14 +96,14 @@ public class DistributedMcastStore extends AbstractStore<McastEvent, McastStoreD ...@@ -96,14 +96,14 @@ public class DistributedMcastStore extends AbstractStore<McastEvent, McastStoreD
96 switch (operation) { 96 switch (operation) {
97 case ADD: 97 case ADD:
98 if (mcastRoutes.putIfAbsent(route, MulticastData.empty()) == null) { 98 if (mcastRoutes.putIfAbsent(route, MulticastData.empty()) == null) {
99 - delegate.notify(new McastEvent(McastEvent.Type.ROUTE_ADDED, 99 + notifyDelegate(new McastEvent(McastEvent.Type.ROUTE_ADDED,
100 - McastRouteInfo.mcastRouteInfo(route))); 100 + mcastRouteInfo(route)));
101 } 101 }
102 break; 102 break;
103 case REMOVE: 103 case REMOVE:
104 if (mcastRoutes.remove(route) != null) { 104 if (mcastRoutes.remove(route) != null) {
105 - delegate.notify(new McastEvent(McastEvent.Type.ROUTE_REMOVED, 105 + notifyDelegate(new McastEvent(McastEvent.Type.ROUTE_REMOVED,
106 - McastRouteInfo.mcastRouteInfo(route))); 106 + mcastRouteInfo(route)));
107 } 107 }
108 break; 108 break;
109 default: 109 default:
...@@ -124,10 +124,10 @@ public class DistributedMcastStore extends AbstractStore<McastEvent, McastStoreD ...@@ -124,10 +124,10 @@ public class DistributedMcastStore extends AbstractStore<McastEvent, McastStoreD
124 124
125 125
126 if (data != null) { 126 if (data != null) {
127 - delegate.notify(new McastEvent(McastEvent.Type.SOURCE_ADDED, 127 + notifyDelegate(new McastEvent(McastEvent.Type.SOURCE_ADDED,
128 - McastRouteInfo.mcastRouteInfo(route, 128 + mcastRouteInfo(route,
129 - data.sinks(), 129 + data.sinks(),
130 - source))); 130 + source)));
131 } 131 }
132 132
133 } 133 }
...@@ -157,19 +157,16 @@ public class DistributedMcastStore extends AbstractStore<McastEvent, McastStoreD ...@@ -157,19 +157,16 @@ public class DistributedMcastStore extends AbstractStore<McastEvent, McastStoreD
157 if (data != null) { 157 if (data != null) {
158 switch (operation) { 158 switch (operation) {
159 case ADD: 159 case ADD:
160 - delegate.notify(new McastEvent( 160 + notifyDelegate(new McastEvent(McastEvent.Type.SINK_ADDED,
161 - McastEvent.Type.SINK_ADDED, 161 + mcastRouteInfo(route, sink,
162 - McastRouteInfo.mcastRouteInfo(route, 162 + data.source())));
163 - sink,
164 - data.source())));
165 break; 163 break;
166 case REMOVE: 164 case REMOVE:
167 if (data != null) { 165 if (data != null) {
168 - delegate.notify(new McastEvent( 166 + notifyDelegate(new McastEvent(McastEvent.Type.SINK_REMOVED,
169 - McastEvent.Type.SINK_REMOVED, 167 + mcastRouteInfo(route,
170 - McastRouteInfo.mcastRouteInfo(route, 168 + sink,
171 - sink, 169 + data.source())));
172 - data.source())));
173 } 170 }
174 break; 171 break;
175 default: 172 default:
......