Fix for NPE due to invalid arguments
Change-Id: I08b83c09c405a0aed0c69628fd5f27b3e5c97ae8
diff --git a/cli/src/main/java/org/onosproject/cli/net/AddOpticalIntentCommand.java b/cli/src/main/java/org/onosproject/cli/net/AddOpticalIntentCommand.java
index 57c4100..1049d90 100644
--- a/cli/src/main/java/org/onosproject/cli/net/AddOpticalIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/AddOpticalIntentCommand.java
@@ -44,12 +44,12 @@
@Argument(index = 0, name = "ingressDevice",
description = "Ingress Device/Port Description",
required = true, multiValued = false)
- String ingressDeviceString = null;
+ String ingressDeviceString = "";
@Argument(index = 1, name = "egressDevice",
description = "Egress Device/Port Description",
required = true, multiValued = false)
- String egressDeviceString = null;
+ String egressDeviceString = "";
@Option(name = "-b", aliases = "--bidirectional",
description = "If this argument is passed the optical link created will be bidirectional, " +
@@ -65,7 +65,6 @@
"Connect point must be in \"deviceUri/portNumber\" format");
DeviceId deviceId = DeviceId.deviceId(splitted[0]);
-
DeviceService deviceService = get(DeviceService.class);
List<Port> ports = deviceService.getPorts(deviceId);
@@ -87,7 +86,8 @@
ConnectPoint egress = createConnectPoint(egressDeviceString);
if (ingress == null || egress == null) {
- print("Could not create optical intent");
+ print("Invalid endpoint(s); could not create optical intent");
+ return;
}
DeviceService deviceService = get(DeviceService.class);