ONOS-1194 - NPE if an appid look up fails

Change-Id: I230c2fc00b67c5a2847a7b215c44937f8362ca40
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 77a7719..0eb6c37 100644
--- a/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java
@@ -22,6 +22,7 @@
 
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
+import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
 import org.onosproject.cli.AbstractShellCommand;
 import org.onosproject.cli.Comparators;
@@ -126,13 +127,18 @@
             instr.add(i.toString());
         }
 
+        ApplicationId appCoreId = coreService.getAppId(flow.appId());
+        String appName = appCoreId == null ?
+                Short.toString(flow.appId())
+                : appCoreId.name();
+
         result.put("flowId", Long.toHexString(flow.id().value()))
                 .put("state", flow.state().toString())
                 .put("bytes", flow.bytes())
                 .put("packets", flow.packets())
                 .put("life", flow.life())
                 .put("tableId", flow.type().toString())
-                .put("appId", coreService.getAppId(flow.appId()).name());
+                .put("appId", appName);
         result.set("selector", crit);
         result.set("treatment", instr);
         return result;