StatisticsManager "started" method may fail 28/828/1
authorGiovanni Meo <gmeo@cisco.com>
Thu, 8 Aug 2013 09:48:24 +0000 (11:48 +0200)
committerGiovanni Meo <gmeo@cisco.com>
Thu, 8 Aug 2013 09:48:24 +0000 (11:48 +0200)
"started" method in the
org.opendaylight.controller.statisticsmanager.internal.StatisticsManager
occasionally can fail to complete, this is because the method tries to
"put" data in clustered caches without checking if the value being
inserted is null or no. Infinispan caches in fact don't support null
value insertion and hence an exception is thrown preventing subsequent
calls to continue. The fix is make sure we don't insert NULL values.

Change-Id: I0037931d73e7e7df9535ef83509e770b45e81c72
Signed-off-by: Giovanni Meo <gmeo@cisco.com>
opendaylight/statisticsmanager/implementation/src/main/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManager.java

index eec183d59573aea1bc7deda423416fd4a27b575b..57dfa91b964956e68336673debbca76288d5a00d 100644 (file)
@@ -170,13 +170,25 @@ public class StatisticsManager implements IStatisticsManager, IReadServiceListen
         // Retrieve current statistics so we don't have to wait for next refresh
         ISwitchManager switchManager = (ISwitchManager) ServiceHelper.getInstance(
                 ISwitchManager.class, container.getName(), this);
-        if (reader != null && switchManager != null) {
+        if ((reader != null) && (switchManager != null)) {
             Set<Node> nodeSet = switchManager.getNodes();
             for (Node node : nodeSet) {
-                flowStatistics.put(node, reader.readAllFlows(node));
-                descriptionStatistics.put(node, reader.readDescription(node));
-                tableStatistics.put(node, reader.readNodeTable(node));
-                nodeConnectorStatistics.put(node, reader.readNodeConnectors(node));
+                List<FlowOnNode> flows = reader.readAllFlows(node);
+                if (flows != null) {
+                    flowStatistics.put(node, flows);
+                }
+                NodeDescription descr = reader.readDescription(node);
+                if (descr != null) {
+                    descriptionStatistics.put(node, descr);
+                }
+                List<NodeTableStatistics> tableStats = reader.readNodeTable(node);
+                if (tableStats != null) {
+                    tableStatistics.put(node, tableStats);
+                }
+                List<NodeConnectorStatistics> ncStats = reader.readNodeConnectors(node);
+                if (ncStats != null) {
+                    nodeConnectorStatistics.put(node, ncStats);
+                }
             }
 
         } else {