Fixing NPE in FlowsListCommand when appId is not properly registered

Change-Id: Ic95b67d33d656d645be6a5a63bfef44a11369544
diff --git a/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java b/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java
index 0be9bd4..de84f51 100644
--- a/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java
@@ -27,6 +27,7 @@
 import org.apache.karaf.shell.commands.Command;
 import org.onosproject.cli.AbstractShellCommand;
 import org.onosproject.cli.Comparators;
+import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
 import org.onosproject.net.Device;
 import org.onosproject.net.DeviceId;
@@ -154,9 +155,10 @@
         print("deviceId=%s, flowRuleCount=%d", d.id(), empty ? 0 : flows.size());
         if (!empty) {
             for (FlowEntry f : flows) {
+                ApplicationId appId = coreService.getAppId(f.appId());
                 print(FMT, Long.toHexString(f.id().value()), f.state(),
                       f.bytes(), f.packets(), f.life(), f.priority(), f.tableId(),
-                      coreService.getAppId(f.appId()).name(),
+                      appId != null ? appId.name() : "<none>",
                       f.payLoad() == null ? null : f.payLoad().payLoad().toString());
                 print(SFMT, f.selector().criteria());
                 print(TFMT, f.treatment());