Sonar suggestions - fixes to potential null pointer dereferences

Change-Id: I4e350a9d72a9322971d5d4f831f1bdf167986b87
diff --git a/core/api/src/main/java/org/onosproject/net/intent/util/IntentFilter.java b/core/api/src/main/java/org/onosproject/net/intent/util/IntentFilter.java
index 99b887f..24be4ef 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/util/IntentFilter.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/util/IntentFilter.java
@@ -132,18 +132,18 @@
 
             if (objective instanceof NextObjective) {
                 nextObjective = (DefaultNextObjective) objective;
-                continue;
-
             } else if (objective instanceof ForwardingObjective) {
                 forwardObjective = (DefaultForwardingObjective) objective;
-                FlowRule flowRule = DefaultFlowRule.builder()
+                FlowRule.Builder builder = DefaultFlowRule.builder()
                         .forDevice(deviceId)
                         .withSelector(forwardObjective.selector())
-                        .withTreatment(nextObjective.next().iterator().next())
                         .withPriority(intent.priority())
                         .fromApp(intent.appId())
-                        .makePermanent()
-                        .build();
+                        .makePermanent();
+                if (nextObjective != null) {
+                    builder.withTreatment(nextObjective.next().iterator().next());
+                }
+                FlowRule flowRule = builder.build();
                 flowEntry = getFlowEntry(flowRule);
 
                 if (flowEntry != null) {