Ray Milkey

ONOS-1194 - NPE if an appid look up fails

Change-Id: I230c2fc00b67c5a2847a7b215c44937f8362ca40
...@@ -22,6 +22,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; ...@@ -22,6 +22,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
22 22
23 import org.apache.karaf.shell.commands.Argument; 23 import org.apache.karaf.shell.commands.Argument;
24 import org.apache.karaf.shell.commands.Command; 24 import org.apache.karaf.shell.commands.Command;
25 +import org.onosproject.core.ApplicationId;
25 import org.onosproject.core.CoreService; 26 import org.onosproject.core.CoreService;
26 import org.onosproject.cli.AbstractShellCommand; 27 import org.onosproject.cli.AbstractShellCommand;
27 import org.onosproject.cli.Comparators; 28 import org.onosproject.cli.Comparators;
...@@ -126,13 +127,18 @@ public class FlowsListCommand extends AbstractShellCommand { ...@@ -126,13 +127,18 @@ public class FlowsListCommand extends AbstractShellCommand {
126 instr.add(i.toString()); 127 instr.add(i.toString());
127 } 128 }
128 129
130 + ApplicationId appCoreId = coreService.getAppId(flow.appId());
131 + String appName = appCoreId == null ?
132 + Short.toString(flow.appId())
133 + : appCoreId.name();
134 +
129 result.put("flowId", Long.toHexString(flow.id().value())) 135 result.put("flowId", Long.toHexString(flow.id().value()))
130 .put("state", flow.state().toString()) 136 .put("state", flow.state().toString())
131 .put("bytes", flow.bytes()) 137 .put("bytes", flow.bytes())
132 .put("packets", flow.packets()) 138 .put("packets", flow.packets())
133 .put("life", flow.life()) 139 .put("life", flow.life())
134 .put("tableId", flow.type().toString()) 140 .put("tableId", flow.type().toString())
135 - .put("appId", coreService.getAppId(flow.appId()).name()); 141 + .put("appId", appName);
136 result.set("selector", crit); 142 result.set("selector", crit);
137 result.set("treatment", instr); 143 result.set("treatment", instr);
138 return result; 144 return result;
......