Ayaka Koshibe
Committed by Gerrit Code Review

Fix for NPE due to invalid arguments

Change-Id: I08b83c09c405a0aed0c69628fd5f27b3e5c97ae8
...@@ -44,12 +44,12 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand { ...@@ -44,12 +44,12 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand {
44 @Argument(index = 0, name = "ingressDevice", 44 @Argument(index = 0, name = "ingressDevice",
45 description = "Ingress Device/Port Description", 45 description = "Ingress Device/Port Description",
46 required = true, multiValued = false) 46 required = true, multiValued = false)
47 - String ingressDeviceString = null; 47 + String ingressDeviceString = "";
48 48
49 @Argument(index = 1, name = "egressDevice", 49 @Argument(index = 1, name = "egressDevice",
50 description = "Egress Device/Port Description", 50 description = "Egress Device/Port Description",
51 required = true, multiValued = false) 51 required = true, multiValued = false)
52 - String egressDeviceString = null; 52 + String egressDeviceString = "";
53 53
54 @Option(name = "-b", aliases = "--bidirectional", 54 @Option(name = "-b", aliases = "--bidirectional",
55 description = "If this argument is passed the optical link created will be bidirectional, " + 55 description = "If this argument is passed the optical link created will be bidirectional, " +
...@@ -65,7 +65,6 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand { ...@@ -65,7 +65,6 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand {
65 "Connect point must be in \"deviceUri/portNumber\" format"); 65 "Connect point must be in \"deviceUri/portNumber\" format");
66 66
67 DeviceId deviceId = DeviceId.deviceId(splitted[0]); 67 DeviceId deviceId = DeviceId.deviceId(splitted[0]);
68 -
69 DeviceService deviceService = get(DeviceService.class); 68 DeviceService deviceService = get(DeviceService.class);
70 69
71 List<Port> ports = deviceService.getPorts(deviceId); 70 List<Port> ports = deviceService.getPorts(deviceId);
...@@ -87,7 +86,8 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand { ...@@ -87,7 +86,8 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand {
87 ConnectPoint egress = createConnectPoint(egressDeviceString); 86 ConnectPoint egress = createConnectPoint(egressDeviceString);
88 87
89 if (ingress == null || egress == null) { 88 if (ingress == null || egress == null) {
90 - print("Could not create optical intent"); 89 + print("Invalid endpoint(s); could not create optical intent");
90 + return;
91 } 91 }
92 92
93 DeviceService deviceService = get(DeviceService.class); 93 DeviceService deviceService = get(DeviceService.class);
......