ONOS-4395 Fix NPE in OpenFlowDeviceProvider

Following gerrit #8858

Change-Id: I55cc4d9ee028e11e099657752a12d2c026893a59
diff --git a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
index a31f38d..bdff790 100644
--- a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
+++ b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
@@ -311,10 +311,6 @@
                                                            List<OFPortStatsEntry> entries) {
         HashSet<PortStatistics> stats = Sets.newHashSet();
 
-        if (entries == null) {
-            return Collections.unmodifiableSet(stats);
-        }
-
         for (OFPortStatsEntry entry : entries) {
             try {
                 if (entry == null || entry.getPortNo() == null || entry.getPortNo().getPortNumber() < 0) {
@@ -793,8 +789,11 @@
                             portStatsReplyList.addAll(portStatsReply.getEntries());
                             portStatsReplies.put(dpid, portStatsReplyList);
                             if (!portStatsReply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
-                                pushPortMetrics(dpid, portStatsReplies.get(dpid));
-                                portStatsReplies.get(dpid).clear();
+                                List<OFPortStatsEntry> statsEntries = portStatsReplies.get(dpid);
+                                if (statsEntries != null) {
+                                    pushPortMetrics(dpid, statsEntries);
+                                    statsEntries.clear();
+                                }
                             }
                         }
                         break;