From 1658c15b4e1abc8a8879cf9336a39bc66ff55f69 Mon Sep 17 00:00:00 2001
From: Lei Xu <x.rayyle@gmail.com>
Date: Tue, 16 Aug 2016 14:42:16 -0700
Subject: [PATCH] fix concurrency issue in Statistics

---
 .../floodlightcontroller/statistics/web/BandwidthResource.java | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/main/java/net/floodlightcontroller/statistics/web/BandwidthResource.java b/src/main/java/net/floodlightcontroller/statistics/web/BandwidthResource.java
index 4b92eeafa..291620a5e 100644
--- a/src/main/java/net/floodlightcontroller/statistics/web/BandwidthResource.java
+++ b/src/main/java/net/floodlightcontroller/statistics/web/BandwidthResource.java
@@ -69,6 +69,9 @@ public class BandwidthResource extends ServerResource {
                 spbs = new HashSet<SwitchPortBandwidth>();
                 //fix concurrency scenario
                 IOFSwitch sw = switchService.getSwitch(dpid);
+                if (sw == null){
+                		return Collections.singletonMap("ERROR", "Switch was not online: " + dpid);
+                }
                 for (OFPortDesc pd : sw.getPorts()) { /* do specific DPID; do all ports */
                     SwitchPortBandwidth spb = statisticsService.getBandwidthConsumption(dpid, pd.getPortNo());
                     if (spb != null) {
-- 
GitLab